MCPcopy Create free account
hub / github.com/serverless/examples / handler

Function handler

aws-golang-auth-examples/functions/auth2/main.go:11–23  ·  view source on GitHub ↗
(request events.APIGatewayCustomAuthorizerRequest)

Source from the content-addressed store, hash-verified

9)
10
11func handler(request events.APIGatewayCustomAuthorizerRequest) (events.APIGatewayCustomAuthorizerResponse, error) {
12 token := request.AuthorizationToken
13 tokenSlice := strings.Split(token, " ")
14 var bearerToken string
15 if len(tokenSlice) > 1 {
16 bearerToken = tokenSlice[len(tokenSlice)-1]
17 }
18 if bearerToken == "" {
19 return events.APIGatewayCustomAuthorizerResponse{}, errors.New("Unauthorized")
20 }
21
22 return generatePolicy("user", "Allow", request.MethodArn, map[string]interface{}{"name": bearerToken}), nil
23}
24
25func main() {
26 lambda.Start(handler)

Callers 1

main_test.goFile · 0.70

Calls 1

generatePolicyFunction · 0.70

Tested by

no test coverage detected