Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Add docs for ProblemDetailsNotFoundHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
akrabat committed Oct 3, 2017
1 parent 2a89342 commit 69a21d0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/book/not-found-handler.md
@@ -0,0 +1,23 @@
# Not Found Handler

This library provides a Not Found handler so that returned 404 responses are in
the problem details format.

This handler will create a problem details `Response` with a `404` status code and
a problem details body that will be rendered in either JSON or XML as required by
the request's `Accept` header.

This handler will only return a response if the request's accept header indicates
that it will accept either JSON or XML.


To use this handler in Expressive add it into your pipeline (usually `pipeline.php`)
immediate before the default `NotFoundHandler`:


```
$app->pipe(\Zend\ProblemDetails\ProblemDetailsNotFoundHandler::class);
$app->pipe(NotFoundHandler::class);
```


19 changes: 19 additions & 0 deletions docs/book/quick-start.md
Expand Up @@ -280,3 +280,22 @@ $app->post('/api/domain/transaction', [
DomainTransactionMiddleware::class,
]);
```

### Not Found handling

When writing APIs you may also want 404 responses be in the accepted content-type.
This package provides `ProblemDetailsNotFoundHandler` which will return a
problem details `Response` with a `404` status if the request can accept either
JSON or XML.

To use this handler in Expressive add it into your pipeline immediate before the
default `NotFoundHandler`:

```
$app->pipe(\Zend\ProblemDetails\ProblemDetailsNotFoundHandler::class);
$app->pipe(NotFoundHandler::class);
```




1 change: 1 addition & 0 deletions mkdocs.yml
Expand Up @@ -8,6 +8,7 @@ pages:
- "Generating Responses": response.md
- "Exceptions": exception.md
- "Error Handling Middleware": middleware.md
- "Not Found Handler": not-found-handler.md
site_name: Problem Details
site_description: 'Problem Details for PSR-7 Applications'
repo_url: 'https://github.com/zendframework/zend-problem-details'
Expand Down

0 comments on commit 69a21d0

Please sign in to comment.