Added context to apig router config and apig context
This commit is contained in:
parent
da00efd4a3
commit
639d28c78e
|
@ -48,6 +48,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "751d4fc4b7be23b18796aed082f5e83d9ba309c184255d4c63d8225cc0048152"
|
||||
inputs-digest = "5da761903d61cf9e47d309477db924d6e310f97fbd7c553ff46af570b65d4356"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
name = "github.com/aws/aws-lambda-go"
|
||||
version = "1.2.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/smartystreets/goconvey"
|
||||
version = "1.6.3"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package lambdarouter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -24,6 +25,7 @@ const (
|
|||
// Fill the Status and Body, or Status and Error to respond.
|
||||
type APIGContext struct {
|
||||
Claims map[string]interface{}
|
||||
Context context.Context
|
||||
Path map[string]string
|
||||
QryStr map[string]string
|
||||
Request *events.APIGatewayProxyRequest
|
||||
|
@ -43,12 +45,14 @@ type APIGRouter struct {
|
|||
params map[string]string
|
||||
prefix string
|
||||
headers map[string]string
|
||||
context context.Context
|
||||
}
|
||||
|
||||
// APIGRouterConfig is used as the input to NewAPIGRouter, request is your incoming
|
||||
// apig request and prefix will be stripped of all incoming request paths. Headers
|
||||
// will be sent with all responses.
|
||||
type APIGRouterConfig struct {
|
||||
Context context.Context
|
||||
Request *events.APIGatewayProxyRequest
|
||||
Prefix string
|
||||
Headers map[string]string
|
||||
|
@ -144,6 +148,7 @@ func (r *APIGRouter) Respond() events.APIGatewayProxyResponse {
|
|||
Path: r.request.PathParameters,
|
||||
QryStr: r.request.QueryStringParameters,
|
||||
Request: r.request,
|
||||
Context: r.context,
|
||||
}
|
||||
if r.request.RequestContext.Authorizer["claims"] != nil {
|
||||
ctx.Claims = r.request.RequestContext.Authorizer["claims"].(map[string]interface{})
|
||||
|
|
Loading…
Reference in New Issue