Select an API Gateway REST API to connect a route to a Lambda function.
+Select an API to see its routes, or create one.
{isWebSocket ? 'WebSocket API' : 'HTTP API'}
+ {isWebSocket + ? <>Messages are routed by{api?.routeSelectionExpression ?? String(resource.metadata.routeSelectionExpression ?? '')}.>
+ : 'Routes send requests to Lambda functions or HTTP backends.'}
+ Loading the API
} + {query.error instanceof Error &&{query.error.message}
} + {api &&No stages yet. Add one below to serve the API.
+ return{url}{stage.invokePath}}
+ Routes
+ {isWebSocket + ? '$connect and $disconnect run when a client connects and leaves; other messages go to the route their action names, or $default.' + : 'The most specific route wins; $default catches every request no other route matches.'} +No routes yet.
} + {api.routes.length > 0 &&| Route | Target | {!isWebSocket &&Access | }|
|---|---|---|---|
{route.routeKey}{isWebSocket && route.returnsResponse && · replies} |
+ {describeTarget(route)} | + {!isWebSocket &&+ + {route.authorizerId && !api.authorizers.some((authorizer) => authorizer.authorizerId === route.authorizerId) && Authorizer {authorizerName(route.authorizerId)}} + | } ++ {confirmDelete === route.routeId + ? + Delete {route.routeKey}? + + + + : } + | +
{error.message}
} +Stages
+ A stage serves a deployment of the routes. With automatic deployment, every change is live right away. +| Stage | Deployment | Updated | |
|---|---|---|---|
{stage.stageName} |
+ {stage.autoDeploy ? 'Automatic' : stage.deploymentId ? {stage.deploymentId} : 'Not deployed'} |
+ {formatDateTime(stage.lastUpdatedAt) ?? '—'} | ++ {!stage.autoDeploy && } + {confirmDelete === stage.stageName + ? + Delete {stage.stageName}? + + + + : } + | +
{notice}
} + {error instanceof Error &&{error.message}
} +| Authorizer | Issuer | Audience | |
|---|---|---|---|
| {authorizer.name} · {authorizer.type} | +{authorizer.issuer ?? '—'} | +{authorizer.audience.join(', ') || '—'} | ++ |
{error.message}
} + > +} + +function CorsSection({cloud, api, runtimeReachable, queryKey}: SectionProps) { + const queryClient = useQueryClient() + const [origins, setOrigins] = useState('') + const [methods, setMethods] = useStateCORS
+ {api.cors ? 'On: browsers on the allowed origins can call this API.' : 'Off: browsers on other sites cannot call this API.'} +{notice}
} + {mutation.error instanceof Error &&{mutation.error.message}
} + > +} + +function HttpTester({cloud, api, runtimeReachable}: {cloud: CloudProvider; api: HttpApiOverview; runtimeReachable: boolean}) { + const [stage, setStage] = useState(api.stages[0]?.stageName ?? '$default') + const [method, setMethod] = useState('GET') + const [path, setPath] = useState(suggestedPath(api.routes)) + const [query, setQuery] = useState('') + const [headers, setHeaders] = useState('{\n "content-type": "application/json"\n}') + const [body, setBody] = useState('') + + useEffect(() => { + setStage(api.stages[0]?.stageName ?? '$default') + setPath(suggestedPath(api.routes)) + // Only when another API is opened; keep what the user typed while this one refreshes. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [api.apiId]) + + const mutation = useMutation({ + mutationFn: () => testApiGatewayRoute(cloud, api.apiId, {path: path.trim(), method, stage, body, headers: parseHeaders(headers), query}), + }) + const result = mutation.data + + returnauthorization header with Bearer and a token.
+ {JSON.stringify(result.headers, null, 2)}{formatResponseBody(result.body)}
+ Send a request to see the response.
} +{result.error}
} + {result.connected && result.messages.length === 0 &&No reply. Check the route sends the function's response back.
} + {result.messages.map((reply, index) =>{formatResponseBody(reply)})}
+ Send a message to see the replies.
} +