Skip to content

Commit 9876646

Browse files
committed
docs: remove Logger dependency on retrieval to address Simon's feedback
1 parent 7410f5a commit 9876646

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

docs/core/event_handler/api_gateway.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ Here's a sample middleware that extracts and injects correlation ID, using `APIG
406406
```
407407

408408
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.
409+
2. [Shared context is available](#sharing-contextual-data) to any middleware, Router and App instances. <br><br> For example, another middleware can now use `app.context.get("correlation_id")` to retrieve it.
410410
3. Get response from the next middleware (if any) or from `/todos` route.
411411
4. You can manipulate headers, body, or status code before returning it.
412412
5. Register one or more middlewares in order of execution.

examples/event_handler_rest/src/middleware_getting_started.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def inject_correlation_id(app: APIGatewayRestResolver, next_middleware: NextMidd
1212
request_id = app.current_event.request_context.request_id # (1)!
1313

1414
# Use API Gateway REST API request ID if caller didn't include a correlation ID
15-
correlation_id = logger.get_correlation_id() or request_id
15+
correlation_id = app.context.get("correlation_id") or request_id
1616

1717
# Inject correlation ID in shared context and Logger
1818
app.append_context(correlation_id=correlation_id) # (2)!

examples/event_handler_rest/src/middleware_global_middlewares_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def inject_correlation_id(app: APIGatewayRestResolver, next_middleware: NextMidd
1818
request_id = app.current_event.request_context.request_id
1919

2020
# Use API Gateway REST API request ID if caller didn't include a correlation ID
21-
correlation_id = logger.get_correlation_id() or request_id
21+
correlation_id = app.context.get("correlation_id") or request_id
2222

2323
# Inject correlation ID in shared context and Logger
2424
app.append_context(correlation_id=correlation_id)

0 commit comments

Comments
 (0)