You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/event-handler/rest.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,18 +130,6 @@ Please [check this issue](https://github.com/aws-powertools/powertools-lambda-ty
130
130
131
131
You can access request details such as headers, query parameters, and body using the `Request` object provided to your route handlers and middleware functions via `reqCtx.req`.
132
132
133
-
### Handling not found routes
134
-
135
-
By default, we return a `404 Not Found` response for any unmatched routes.
136
-
137
-
You can use the `notFound()` method as a higher-order function or class method decorator to override this behavior, and return a custom response.
You can use the `errorHandler()` method as a higher-order function or class method decorator to define a custom error handler for errors thrown in your route handlers or middleware.
@@ -158,6 +146,20 @@ Error handlers receive the error object and the request context as arguments, an
We provide built-in error handlers for common routing errors so you don't have to specify the Error type explicitly.
152
+
153
+
You can use the `notFound()` and `methodNotAllowed()` methods as higher-order functions or class method decorators to customize error responses for unmatched routes and unsupported HTTP methods.
154
+
155
+
By default, we return a `404 Not Found` response for unmatched routes.
You can throw HTTP errors in your route handlers to stop execution and return specific HTTP status codes and messages. Event Handler provides a set of built-in HTTP error classes that you can use to throw common HTTP errors.
@@ -439,11 +441,10 @@ For convenience, these are the default CORS settings applied when you register t
|`allowHeaders`|`[Authorization, Content-Type, X-Amz-Date, X-Api-Key, X-Amz-Security-Token]`| Specifies the allowed headers that can be used in the actual request. |
444
446
|`exposeHeaders`|`[]`| Any additional header beyond the [safe listed by CORS specification](https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_response_header){target="_blank"}. |
445
447
|`credentials`|`false`| Only necessary when you need to expose cookies, authorization headers or TLS client certificates. |
446
-
|`maxAge`|`0`| Indicates how long the results of a preflight request can be cached. Value is in seconds. |
0 commit comments