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/core/event_handler/api_gateway.md
+86-2
Original file line number
Diff line number
Diff line change
@@ -357,7 +357,7 @@ You can access the raw payload via `body` property, or if it's a JSON string you
357
357
358
358
#### Headers
359
359
360
-
Similarly to [Query strings](#query-strings), you can access headers as dictionary via `app.current_event.headers`, or by name via `get_header_value`.
360
+
Similarly to [Query strings](#query-strings-and-payload), you can access headers as dictionary via `app.current_event.headers`, or by name via `get_header_value`.
361
361
362
362
=== "app.py"
363
363
@@ -377,6 +377,66 @@ Similarly to [Query strings](#query-strings), you can access headers as dictiona
377
377
return app.resolve(event, context)
378
378
```
379
379
380
+
### Raising HTTP errors
381
+
382
+
You can easily raise any HTTP Error back to the client using `ServiceError` exception.
383
+
384
+
!!! info "If you need to send custom headers, use [Response](#fine-grained-responses) class instead."
385
+
386
+
Additionally, we provide pre-defined errors for the most popular ones such as HTTP 400, 401, 404, 500.
387
+
388
+
389
+
=== "app.py"
390
+
391
+
```python hl_lines="4-10 20 25 30 35 39"
392
+
from aws_lambda_powertools import Logger, Tracer
393
+
from aws_lambda_powertools.logging import correlation_paths
394
+
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
395
+
from aws_lambda_powertools.event_handler.exceptions import (
|**POWERTOOLS_LOG_DEDUPLICATION_DISABLED**| Disables log deduplication filter protection to use Pytest Live Log feature |[Logging](./core/logger)|`false`|
232
+
|**POWERTOOLS_EVENT_HANDLER_DEBUG**| Enables debugging mode for event handler |[Event Handler](./core/event_handler/api_gateway.md#debug-mode)|`false`|
0 commit comments