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