Skip to content

Instantly share code, notes, and snippets.

@rpgreen
Last active March 10, 2023 02:10
Show Gist options
  • Save rpgreen/c127aa4ebbcaa9026be7 to your computer and use it in GitHub Desktop.
Save rpgreen/c127aa4ebbcaa9026be7 to your computer and use it in GitHub Desktop.

Revisions

  1. rpgreen revised this gist Jan 4, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -49,8 +49,6 @@ paths:
    responses:
    default:
    statusCode: "200"
    responseTemplates:
    application/json: "__passthrough__"
    https://.*:
    statusCode: "302"
    responseParameters:
  2. rpgreen revised this gist Jan 4, 2016. No changes.
  3. rpgreen revised this gist Jan 4, 2016. No changes.
  4. rpgreen created this gist Jan 4, 2016.
    92 changes: 92 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    ---
    swagger: "2.0"
    basePath: "/test"
    schemes:
    - "https"
    paths:
    /lambdaredirect-default:
    get:
    produces:
    - "application/json"
    parameters: []
    responses:
    200:
    description: "200 response"
    schema:
    $ref: "#/definitions/Empty"
    headers: {}
    302:
    description: "302 response"
    headers:
    Location:
    type: "string"
    x-amazon-apigateway-integration:
    responses:
    default:
    statusCode: "302"
    responseParameters:
    method.response.header.Location: "integration.response.body.location"
    uri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:[ACCOUNT_ID]:function:redirect-default/invocations"
    httpMethod: "POST"
    type: "aws"
    /lambdaredirect-error:
    get:
    produces:
    - "application/json"
    parameters: []
    responses:
    200:
    description: "200 response"
    schema:
    $ref: "#/definitions/Empty"
    headers: {}
    302:
    description: "302 response"
    headers:
    Location:
    type: "string"
    x-amazon-apigateway-integration:
    responses:
    default:
    statusCode: "200"
    responseTemplates:
    application/json: "__passthrough__"
    https://.*:
    statusCode: "302"
    responseParameters:
    method.response.header.Location: "integration.response.body.errorMessage"
    responseTemplates:
    application/json: "## intentionally blank"
    uri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:[ACCOUNT_ID]]:function:redirect-error/invocations"
    httpMethod: "POST"
    type: "aws"
    securityDefinitions:
    sigv4:
    type: "apiKey"
    name: "Authorization"
    in: "header"
    x-amazon-apigateway-authtype: "awsSigv4"
    definitions:
    Empty:
    type: "object"



    --
    Lambda Function "redirect-default":
    --

    exports.handler = function(event, context) {
    context.succeed({
    location : "https://example.com"
    });
    };

    --
    Lambda Function "redirect-error":
    --
    exports.handler = function(event, context) {
    context.fail("https://example.com");
    };