Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


slim:4:response

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
slim:4:response [2020/10/07 17:57]
y2sunlight [The Response Body]
slim:4:response [2020/10/07 21:20] (現在)
y2sunlight
行 1: 行 1:
-> 編集中 
- 
 ====== Slim4 レスポンス ====== ====== Slim4 レスポンス ======
 Version 4.5.0 Version 4.5.0
行 16: 行 14:
   * [[slim:4:routing|Slim4 ルーティング]]   * [[slim:4:routing|Slim4 ルーティング]]
   * [[slim:4:middleware|Slim4 ミドルウェア]]   * [[slim:4:middleware|Slim4 ミドルウェア]]
 +  * [[slim:4:cookbook|Slim4  クックブック]]
  
 本章は以下のサイトの **The Response** のセクションを翻訳し若干の補足を加えたのもです。 本章は以下のサイトの **The Response** のセクションを翻訳し若干の補足を加えたのもです。
行 151: 行 150:
 \\ \\
  
-===== The Response Body =====+===== レスポンスボディ =====
  
 HTTPレスポンスには通常、ボディがあります。 HTTPレスポンスには通常、ボディがあります。
行 182: 行 181:
 $body->write('Hello'); $body->write('Hello');
 </code> </code>
- 
-You can also replace the PSR-7 Response object’s body with an entirely new ''StreamInterface'' instance. 
- 
-This is particularly useful when you want to pipe content from a remote destination (e.g. the filesystem or a remote API) into the HTTP response. You can replace the PSR-7 Response object’s body with its ''withBody(StreamInterface $body)'' method. Its argument MUST be an instance of ''Psr\Http\Message\StreamInterface''. 
  
 PSR-7 Responseオブジェクトのボディをまったく新しい ''StreamInterface'' インスタンスに置き換えることもできます。 PSR-7 Responseオブジェクトのボディをまったく新しい ''StreamInterface'' インスタンスに置き換えることもできます。
  
-これは、コンテンツをリモートの宛先(ファイルシステムやリモートAPIなど)からHTTP応答にパイプ処理する場合に特に便利です。 PSR-7Responseオブジェクトの本体その '' withBodyStreamInterface $ body) ''メソッド置き換えることができます。 その引数は、 '' Psr \ Http \ Message \ StreamInterface ''のインスタンスでなければなりません。+これは、コンテンツをリモートの宛先(例えば、ファイルシステムやリモートAPIなど)からHTTPレスポンスにパイプ処理する場合に特に便利です。PSR-7 Responseオブジェクトのボディを ''withBody(StreamInterface $body)'' メソッドを使って置き換えることができます。 その引数は、''Psr\Http\Message\StreamInterface'' のインスタンスでなければなりません( ''MUST'' )
  
 <code php> <code php>
行 198: 行 193:
 </code> </code>
  
->**Reminder** +> **注意** 
->The Response object is immutable. This method returns a copy of the Response object that contains the new body. +> Responseオブジェクトは不変です。このメソッドは、新しい本文を含むResponseオブジェクトのコピーを返します。
- +
-> **リマインダー** +
-> Responseオブジェクトは不変です。 このメソッドは、新しい本文を含むResponseオブジェクトのコピーを返します。+
  
 \\ \\
  
-===== Returning JSON =====+===== JSONを返す =====
  
-In it’s simplest form, JSON data can be returned with a default 200 HTTP status code. +最も単純な形式では、JSONデータはデフォルトの 200 HTTPステータスコードを使用して返すことができます。
- +
-最も単純な形式では、JSONデータはデフォルトの200HTTPステータスコード返すことができます。+
  
 <code php> <code php>
行 220: 行 210:
           ->withHeader('Content-Type', 'application/json');           ->withHeader('Content-Type', 'application/json');
 </code> </code>
- 
-We can also return JSON data with a custom HTTP status code. 
  
 カスタムHTTPステータスコードを使用してJSONデータを返すこともできます。 カスタムHTTPステータスコードを使用してJSONデータを返すこともできます。
行 235: 行 223:
 </code> </code>
  
->**Reminder** 
 >The Response object is immutable. This method returns a copy of the Response object that has a new Content-Type header. This method is destructive, and it replaces the existing Content-Type header. >The Response object is immutable. This method returns a copy of the Response object that has a new Content-Type header. This method is destructive, and it replaces the existing Content-Type header.
  
-> **リマインダー** +> **注意** 
-> Responseオブジェクトは不変です。 このメソッドは、新しいContent-Typeヘッダーを持つResponseオブジェクトのコピーを返します。 このメソッドは破壊的であり、既存のContent-Typeヘッダーを置き換えます。+> Responseオブジェクトは不変です。このメソッドは、新しいContent-Typeヘッダーを持つResponseオブジェクトのコピーを返します。このメソッドは破壊的であり、既存のContent-Typeヘッダーを置き換えます。
  
 \\ \\
  
-===== Returning a Redirect ===== +===== リダイレクトを返す =====
- +
-You can redirect the HTTP client by using the Location header.+
  
 Locationヘッダーを使用して、HTTPクライアントをリダイレクトできます。 Locationヘッダーを使用して、HTTPクライアントをリダイレクトできます。
slim/4/response.1602061059.txt.gz · 最終更新: 2020/10/07 17:57 by y2sunlight