How to use the @aws-cdk/aws-apigateway.MockIntegration function in @aws-cdk/aws-apigateway

To help you get started, we’ve selected a few @aws-cdk/aws-apigateway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fogfish / aws-cdk-pure / hoc / src / gateway.ts View on Github external
export const CORS = (endpoint: api.Resource, props: AccessControl = {}): api.Resource => {
  const mthd = `'${props.method ? props.method.join(',') : 'GET,POST,PUT,DELETE,OPTIONS'}'`
  const head = `'${props.header ? props.header.join(',') : 'Content-Type,Authorization,Accept,Origin'}'`
  const origin = `'${props.origin || '*'}'`
  const mock = new api.MockIntegration({
    integrationResponses: [
      {
        responseParameters: {
          "method.response.header.Access-Control-Allow-Headers": head,
          "method.response.header.Access-Control-Allow-Methods": mthd,
          "method.response.header.Access-Control-Allow-Origin": origin,
          "method.response.header.Access-Control-Max-Age": "'600'",
        },
        selectionPattern: '\\d{3}',
        statusCode: '200',
      },
    ],
    passthroughBehavior: api.PassthroughBehavior.WHEN_NO_MATCH,
    requestTemplates: {
      "application/json": "{\"statusCode\": 200}"
    },