Skip to content

Commit 27d2720

Browse files
author
Michael Brewer
committed
docs: fix syntax errors and line highlights
1 parent 6869155 commit 27d2720

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Diff for: docs/core/event_handler/api_gateway.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ You can also nest paths as configured earlier in [our sample infrastructure](#re
298298
@app.get("/<message>/<name>")
299299
@tracer.capture_method
300300
def get_message(message, name):
301-
return {"message": f"{message}, {name}}"}
301+
return {"message": f"{message}, {name}"}
302302

303303
# You can continue to use other utilities just as before
304304
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_REST)
@@ -461,7 +461,7 @@ def get_hello_you():
461461
payload = app.current_event.body
462462

463463
name = app.current_event.get_query_string_value(name="name", default_value="")
464-
return {"message": f"hello {name}}"}
464+
return {"message": f"hello {name}"}
465465

466466
def lambda_handler(event, context):
467467
return app.resolve(event, context)
@@ -481,7 +481,7 @@ def get_hello_you():
481481
headers_as_dict = app.current_event.headers
482482
name = app.current_event.get_header_value(name="X-Name", default_value="")
483483

484-
return {"message": f"hello {name}}"}
484+
return {"message": f"hello {name}"}
485485

486486
def lambda_handler(event, context):
487487
return app.resolve(event, context)
@@ -768,7 +768,8 @@ You can use the `Response` class to have full control over the response, for exa
768768

769769
=== "app.py"
770770

771-
```python hl_lines="10-14"
771+
```python hl_lines="11-16"
772+
import json
772773
from aws_lambda_powertools.event_handler.api_gateway import APIGatewayRestResolver, Response
773774

774775
app = APIGatewayRestResolver()
@@ -778,10 +779,11 @@ You can use the `Response` class to have full control over the response, for exa
778779
payload = json.dumps({"message": "I'm a teapot"})
779780
custom_headers = {"X-Custom": "X-Value"}
780781

781-
return Response(status_code=418,
782-
content_type="application/json",
783-
body=payload,
784-
headers=custom_headers
782+
return Response(
783+
status_code=418,
784+
content_type="application/json",
785+
body=payload,
786+
headers=custom_headers,
785787
)
786788

787789
def lambda_handler(event, context):
@@ -974,7 +976,7 @@ def lambda_handler(event, context):
974976

975977
You can instruct API Gateway handler to use a custom serializer to best suit your needs, for example take into account Enums when serializing.
976978

977-
```python hl_lines="19-20 24" title="Using a custom JSON serializer for responses"
979+
```python hl_lines="21-22 26" title="Using a custom JSON serializer for responses"
978980
import json
979981
from enum import Enum
980982
from json import JSONEncoder
@@ -1025,7 +1027,7 @@ Let's assume you have `app.py` as your Lambda function entrypoint and routes in
10251027

10261028
We import **Router** instead of **APIGatewayRestResolver**; syntax wise is exactly the same.
10271029

1028-
```python hl_lines="4 8 12 15 21"
1030+
```python hl_lines="5 8 12 15 21"
10291031
import itertools
10301032
from typing import Dict
10311033

@@ -1221,7 +1223,7 @@ This sample project contains a Users function with two distinct set of routes, `
12211223

12221224
=== "src/users/main.py"
12231225

1224-
```python hl_lines="9 15-16"
1226+
```python hl_lines="8 14-15"
12251227
from typing import Dict
12261228

12271229
from aws_lambda_powertools import Logger, Tracer
@@ -1356,7 +1358,7 @@ You can test your routes by passing a proxy event request where `path` and `http
13561358
def test_lambda_handler(lambda_context):
13571359
minimal_event = {
13581360
"path": "/hello",
1359-
"httpMethod": "GET"
1361+
"httpMethod": "GET",
13601362
"requestContext": { # correlation ID
13611363
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
13621364
}

Diff for: docs/tutorial/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ Let's expand our application with custom metrics using AWS SDK to see how it wor
822822
def add_greeting_metric(service: str = "APP"):
823823
function_name = os.getenv("AWS_LAMBDA_FUNCTION_NAME", "undefined")
824824
service_dimension = {"Name": "service", "Value": service}
825-
function_dimension = {"Name": "function_name": "Value": function_name}
825+
function_dimension = {"Name": "function_name", "Value": function_name}
826826
is_cold_start = True
827827

828828
global cold_start

0 commit comments

Comments
 (0)