このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 最新のリビジョン 両方とも次のリビジョン | ||
psr:psr15 [2020/07/28 15:10] y2sunlight [1.2 ミドルウェア] |
psr:psr15 [2020/07/28 15:17] y2sunlight |
||
---|---|---|---|
行 1: | 行 1: | ||
- | > 編集中 | ||
- | |||
====== PSR-15: HTTP Server Request Handlers ====== | ====== PSR-15: HTTP Server Request Handlers ====== | ||
行 84: | 行 82: | ||
==== 1.3 レスポンスの生成 ==== | ==== 1.3 レスポンスの生成 ==== | ||
- | It is RECOMMENDED that any middleware or request handler that generates a response will either compose a prototype of a PSR-7 ResponseInterface or a factory capable of generating a ResponseInterface instance in order to prevent dependence on a specific HTTP message implementation. | + | 応答を生成するミドルウェアまたはリクエストハンドラーは、PSR-7の '' |
- | + | ||
- | 応答を生成するミドルウェアまたはリクエストハンドラーは、PSR-7の '' | + | |
\\ | \\ | ||
行 92: | 行 88: | ||
==== 1.4 例外のハンドリング ==== | ==== 1.4 例外のハンドリング ==== | ||
- | It is RECOMMENDED that any application using middleware includes a component that catches exceptions and converts them into responses. This middleware SHOULD be the first component executed and wrap all further processing to ensure that a response is always generated. | + | ミドルウェアを使用するアプリケーションは、例外をキャッチしてそれらをレスポンスに変換するコンポーネントを含むことが推奨されます( '' |
- | + | ||
- | ミドルウェアを使用するアプリケーションは、例外をキャッチしてそれらをレスポンスに変換するコンポーネントを含むことが推奨されます( '' | + | |
\\ | \\ | ||
行 101: | 行 95: | ||
==== 2.1 Psr\Http\Server\RequestHandlerInterface ==== | ==== 2.1 Psr\Http\Server\RequestHandlerInterface ==== | ||
- | |||
- | The following interface MUST be implemented by request handlers. | ||
リクエストハンドラーは次のインターフェースを実装する必要があります( '' | リクエストハンドラーは次のインターフェースを実装する必要があります( '' | ||
行 113: | 行 105: | ||
/** | /** | ||
- | * Handles a server request and produces a response. | ||
* サーバーリクエストを処理し、レスポンスを生成します。 | * サーバーリクエストを処理し、レスポンスを生成します。 | ||
* | * | ||
- | * An HTTP request handler process an HTTP request in order to produce an | ||
- | * HTTP response. | ||
* HTTPリクエストハンドラーは、HTTPレスポンスを生成するためにHTTPリクエストを処理します。 | * HTTPリクエストハンドラーは、HTTPレスポンスを生成するためにHTTPリクエストを処理します。 | ||
*/ | */ | ||
行 123: | 行 112: | ||
{ | { | ||
/** | /** | ||
- | * Handles a request and produces a response. | ||
* リクエストを処理し、レスポンスを生成します。 | * リクエストを処理し、レスポンスを生成します。 | ||
* | * | ||
- | * May call other collaborating code to generate the response. | ||
* レスポンスを生成するために、他の協調するコードを呼び出すことができます。 | * レスポンスを生成するために、他の協調するコードを呼び出すことができます。 | ||
*/ | */ | ||
行 136: | 行 123: | ||
==== 2.2 Psr\Http\Server\MiddlewareInterface ==== | ==== 2.2 Psr\Http\Server\MiddlewareInterface ==== | ||
- | |||
- | The following interface MUST be implemented by compatible middleware components. | ||
互換性のあるミドルウェアコンポーネントは次のインターフェースを実装する必要があります( '' | 互換性のあるミドルウェアコンポーネントは次のインターフェースを実装する必要があります( '' | ||
行 148: | 行 133: | ||
/** | /** | ||
- | * Participant in processing a server request and response. | ||
* サーバーのリクエストとレスポンスを処理する参加者。 | * サーバーのリクエストとレスポンスを処理する参加者。 | ||
* | * | ||
- | * An HTTP middleware component participates in processing an HTTP message: | ||
- | * by acting on the request, generating the response, or forwarding the | ||
- | * request to a subsequent middleware and possibly acting on its response. | ||
* HTTPミドルウェアコンポーネントは、HTTPメッセージの処理に参加します: | * HTTPミドルウェアコンポーネントは、HTTPメッセージの処理に参加します: | ||
* つまり、リクエストに基づいて動作するか、レスポンスを生成するか、 | * つまり、リクエストに基づいて動作するか、レスポンスを生成するか、 | ||
- | * またはリクエストを後続のミドルウェアに転送し、場合によってはそのレスポンスに基づいて動作します。 | + | * または リクエストを後続のミドルウェアに転送し場合によってはそのレスポンスに基づいて動作します。 |
*/ | */ | ||
interface MiddlewareInterface | interface MiddlewareInterface | ||
{ | { | ||
/** | /** | ||
- | * Process an incoming server request. | ||
* 着信サーバー要求を処理します。 | * 着信サーバー要求を処理します。 | ||
* | * | ||
- | * Processes an incoming server request in order to produce a response. | ||
- | * If unable to produce the response itself, it may delegate to the provided | ||
- | * request handler to do so. | ||
* レスポンスを生成するために、着信サーバーリクエストを処理します。 | * レスポンスを生成するために、着信サーバーリクエストを処理します。 | ||
* レスポンス自体を生成できない場合は、それをするのに提供されたリクエストハンドラーに委任します。 | * レスポンス自体を生成できない場合は、それをするのに提供されたリクエストハンドラーに委任します。 |