Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit b4b16a4

Browse files
authored
Merge pull request #114 from kidylee/master
Change the document for PR#33
2 parents 310bb46 + ce34a43 commit b4b16a4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,22 @@ $ aws cloudformation deploy --template-file output-sam.yaml --stack-name YOUR_ST
108108
Using the CloudFormation console, you can find the URL for the newly created API endpoint in the `Outputs` tab of the sample stack - it looks sample like this: `https://xxxxxxxxx.execute-api.xx-xxxx-x.amazonaws.com/Prod/pets`. Open a browser window and try to call the URL.
109109

110110
## API Gateway context and stage variables
111-
The `RequestAccessor` object, and therefore `GinLambda`, automatically marshals the API Gateway request context and stage variables objects and stores them in custom headers in the request: `X-GinLambda-ApiGw-Context` and `X-GinLambda-ApiGw-StageVars`. While you could manually unmarshal the json content into the `events.APIGatewayProxyRequestContext` and `map[string]string` objects, the library exports two utility methods to give you easy access to the data.
111+
~~The `RequestAccessor` object, and therefore `GinLambda`, automatically marshals the API Gateway request context and stage variables objects and stores them in custom headers in the request: `X-GinLambda-ApiGw-Context` and `X-GinLambda-ApiGw-StageVars`. While you could manually unmarshal the json content into the `events.APIGatewayProxyRequestContext` and `map[string]string` objects, the library exports two utility methods to give you easy access to the data.~~
112+
113+
The gateway context, stage variables and lambda runtime variables are automatically populate to the context.
112114

113115
```go
114116
// the methods are available in your instance of the GinLambda
115-
// object and receive the http.Request object
116-
apiGwContext := ginLambda.GetAPIGatewayContext(c.Request)
117-
apiGwStageVars := ginLambda.GetAPIGatewayStageVars(c.Request)
117+
// object and receive the context
118+
apiGwContext := ginLambda.GetAPIGatewayContextFromContext(ctx)
119+
apiGwStageVars := ginLambda.GetStageVarsFromContext(ctx)
120+
runtimeContext := ginLambda.GetRuntimeContextFromContext(ctx)
118121

119122
// you can access the properties of the context directly
120123
log.Println(apiGwContext.RequestID)
121124
log.Println(apiGwContext.Stage)
125+
log.Println(runtimeContext.InvokedFunctionArn)
126+
122127

123128
// stage variables are stored in a map[string]string
124129
stageVarValue := apiGwStageVars["MyStageVar"]

0 commit comments

Comments
 (0)