Skip to content

Commit b7bcb08

Browse files
committed
docs - refactor references of with kwargs to , remove **lwargs references.
1 parent 03d15fa commit b7bcb08

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

docs/core/event_handler/api_gateway.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ stateDiagram
370370
371371
EventHandler: GET /todo
372372
Before: Before response
373-
Next: get_response()
373+
Next: next_middleware()
374374
MiddlewareLoop: Middleware loop
375375
AfterResponse: After response
376376
MiddlewareFinished: Modified response
@@ -394,8 +394,7 @@ A middleware is a function you register per route to **intercept** or **enrich**
394394
Each middleware function receives the following arguments:
395395

396396
1. **app**. An Event Handler instance so you can access incoming request information, Lambda context, etc.
397-
2. **get_response**. A function to get the next middleware or route's response.
398-
3. **`**kwargs`**. Middleware keyword arguments that are propagated in the chain.
397+
2. **next_middleware**. A function to get the next middleware or route's response.
399398

400399
Here's a sample middleware that extracts and injects correlation ID, using `APIGatewayRestResolver` (works for any [Resolver](#event-resolvers)):
401400

@@ -406,7 +405,7 @@ Here's a sample middleware that extracts and injects correlation ID, using `APIG
406405
```
407406

408407
1. You can access current request like you normally would.
409-
2. [Shared context is available](#sharing-contextual-data) to any middleware, Router and App instances. <br/ ><br/> Alternatively, you can use `**context` kwargs which will only be available for middlewares.
408+
2. [Shared context is available](#sharing-contextual-data) to any middleware, Router and App instances.
410409
3. Get response from the next middleware (if any) or from `/todos` route.
411410
4. You can manipulate headers, body, or status code before returning it.
412411
5. Register one or more middlewares in order of execution.
@@ -506,7 +505,7 @@ While there isn't anything special on how to use [`try/catch`](https://docs.pyth
506505

507506
=== "Unhandled exception from route handler"
508507

509-
An exception wasn't caught by any middleware during `get_response()` block, therefore it propagates all the way back to the client as HTTP 500.
508+
An exception wasn't caught by any middleware during `next_middleware()` block, therefore it propagates all the way back to the client as HTTP 500.
510509

511510
<center>
512511
![Unhandled exceptions](../../media/middlewares_unhandled_route_exception-light.svg#only-light)
@@ -570,7 +569,7 @@ Middlewares can add subtle improvements to request/response processing, but also
570569
Keep the following in mind when authoring middlewares for Event Handler:
571570

572571
1. **Use built-in features over middlewares**. We include built-in features like [CORS](#cors), [compression](#compress), [binary responses](#binary-responses), [global exception handling](#exception-handling), and [debug mode](#debug-mode) to reduce the need for middlewares.
573-
2. **Call the next middleware**. Return the result of `get_response(app, **kwargs)`, or a [Response object](#fine-grained-responses) when you want to [return early](#returning-early).
572+
2. **Call the next middleware**. Return the result of `next_middleware(app)`, or a [Response object](#fine-grained-responses) when you want to [return early](#returning-early).
574573
3. **Keep a lean scope**. Focus on a single task per middleware to ease composability and maintenance. In [debug mode](#debug-mode), we also print out the order middlewares will be triggered to ease operations.
575574
4. **Catch your own exceptions**. Catch and handle known exceptions to your logic. Unless you want to raise [HTTP Errors](#raising-http-errors), or propagate specific exceptions to the client. To catch all and any exceptions, we recommend you use the [exception_handler](#exception-handling) decorator.
576575
5. **Use context to share data**. Use `app.append_context` to [share contextual data](#sharing-contextual-data) between middlewares and route handlers, and `app.context.get(key)` to fetch them. We clear all contextual data at the end of every request.

0 commit comments

Comments
 (0)