zuplo 6.67.32 → 6.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/docs/_index.md +44 -0
- package/docs/ai-gateway/apps.mdx +28 -0
- package/docs/ai-gateway/custom-providers.mdx +54 -0
- package/docs/ai-gateway/getting-started.mdx +224 -0
- package/docs/ai-gateway/guardrails.mdx +65 -0
- package/docs/ai-gateway/integrations/ai-sdk.mdx +109 -0
- package/docs/ai-gateway/integrations/claude-code.mdx +49 -0
- package/docs/ai-gateway/integrations/codex.mdx +78 -0
- package/docs/ai-gateway/integrations/goose.mdx +104 -0
- package/docs/ai-gateway/integrations/langchain.mdx +66 -0
- package/docs/ai-gateway/integrations/openai.mdx +99 -0
- package/docs/ai-gateway/introduction.mdx +85 -0
- package/docs/ai-gateway/managing-apps.mdx +46 -0
- package/docs/ai-gateway/managing-providers.mdx +66 -0
- package/docs/ai-gateway/managing-teams.mdx +63 -0
- package/docs/ai-gateway/policies/akamai-ai-firewall.mdx +125 -0
- package/docs/ai-gateway/policies/comet-opik-tracing.mdx +139 -0
- package/docs/ai-gateway/policies/galileo-tracing.mdx +147 -0
- package/docs/ai-gateway/providers.mdx +32 -0
- package/docs/ai-gateway/teams.mdx +38 -0
- package/docs/ai-gateway/universal-api.mdx +43 -0
- package/docs/ai-gateway/usage-limits.mdx +89 -0
- package/docs/api-management/introduction.md +127 -0
- package/docs/articles/accounts/audit-logs.mdx +227 -0
- package/docs/articles/accounts/billing.mdx +25 -0
- package/docs/articles/accounts/default-api-key.mdx +30 -0
- package/docs/articles/accounts/delete-account.mdx +36 -0
- package/docs/articles/accounts/enterprise-sso.mdx +116 -0
- package/docs/articles/accounts/managing-account-members.mdx +45 -0
- package/docs/articles/accounts/managing-project-members.mdx +37 -0
- package/docs/articles/accounts/members-and-roles.mdx +21 -0
- package/docs/articles/accounts/roles-and-permissions.mdx +115 -0
- package/docs/articles/accounts/zuplo-api-keys.mdx +94 -0
- package/docs/articles/add-api-to-backstage.mdx +216 -0
- package/docs/articles/advanced-path-matching.mdx +139 -0
- package/docs/articles/api-key-administration.mdx +47 -0
- package/docs/articles/api-key-api.mdx +220 -0
- package/docs/articles/api-key-authentication.mdx +195 -0
- package/docs/articles/api-key-buckets.mdx +61 -0
- package/docs/articles/api-key-end-users.mdx +52 -0
- package/docs/articles/api-key-leak-detection.mdx +75 -0
- package/docs/articles/api-key-management.mdx +100 -0
- package/docs/articles/api-key-react-component.mdx +90 -0
- package/docs/articles/api-key-service-limits.mdx +14 -0
- package/docs/articles/archiving-requests-to-storage.mdx +119 -0
- package/docs/articles/branch-based-deployments.mdx +184 -0
- package/docs/articles/bypass-policy-for-testing.mdx +117 -0
- package/docs/articles/check-ip-address.mdx +17 -0
- package/docs/articles/ci-cd-azure/basic-deployment.mdx +49 -0
- package/docs/articles/ci-cd-azure/deploy-and-test.mdx +47 -0
- package/docs/articles/ci-cd-azure/local-testing.mdx +59 -0
- package/docs/articles/ci-cd-azure/multi-stage-deployment.mdx +88 -0
- package/docs/articles/ci-cd-azure/pr-preview-environments.mdx +50 -0
- package/docs/articles/ci-cd-azure/tag-based-releases.mdx +37 -0
- package/docs/articles/ci-cd-bitbucket/basic-deployment.mdx +27 -0
- package/docs/articles/ci-cd-bitbucket/deploy-and-test.mdx +41 -0
- package/docs/articles/ci-cd-bitbucket/local-testing.mdx +34 -0
- package/docs/articles/ci-cd-bitbucket/multi-stage-deployment.mdx +52 -0
- package/docs/articles/ci-cd-bitbucket/pr-preview-environments.mdx +46 -0
- package/docs/articles/ci-cd-bitbucket/tag-based-releases.mdx +27 -0
- package/docs/articles/ci-cd-circleci/basic-deployment.mdx +34 -0
- package/docs/articles/ci-cd-circleci/deploy-and-test.mdx +44 -0
- package/docs/articles/ci-cd-circleci/local-testing.mdx +50 -0
- package/docs/articles/ci-cd-circleci/multi-stage-deployment.mdx +82 -0
- package/docs/articles/ci-cd-circleci/pr-preview-environments.mdx +47 -0
- package/docs/articles/ci-cd-circleci/tag-based-releases.mdx +38 -0
- package/docs/articles/ci-cd-github/basic-deployment.mdx +48 -0
- package/docs/articles/ci-cd-github/cleanup-on-branch-delete.mdx +123 -0
- package/docs/articles/ci-cd-github/deploy-and-test.mdx +82 -0
- package/docs/articles/ci-cd-github/local-testing.mdx +102 -0
- package/docs/articles/ci-cd-github/multi-stage-deployment.mdx +136 -0
- package/docs/articles/ci-cd-github/pr-preview-environments.mdx +106 -0
- package/docs/articles/ci-cd-github/tag-based-releases.mdx +99 -0
- package/docs/articles/ci-cd-gitlab/basic-deployment.mdx +28 -0
- package/docs/articles/ci-cd-gitlab/deploy-and-test.mdx +44 -0
- package/docs/articles/ci-cd-gitlab/local-testing.mdx +39 -0
- package/docs/articles/ci-cd-gitlab/mr-preview-environments.mdx +52 -0
- package/docs/articles/ci-cd-gitlab/multi-stage-deployment.mdx +64 -0
- package/docs/articles/ci-cd-gitlab/tag-based-releases.mdx +28 -0
- package/docs/articles/composite-policy-reference.mdx +284 -0
- package/docs/articles/configuring-auth0-for-mcp-auth.mdx +186 -0
- package/docs/articles/configuring-okta-for-mcp-auth.mdx +208 -0
- package/docs/articles/convert-urls-to-openapi.mdx +62 -0
- package/docs/articles/cors.mdx +447 -0
- package/docs/articles/custom-audit-log-policy.mdx +95 -0
- package/docs/articles/custom-ci-cd-azure.mdx +81 -0
- package/docs/articles/custom-ci-cd-bitbucket.mdx +80 -0
- package/docs/articles/custom-ci-cd-circleci.mdx +78 -0
- package/docs/articles/custom-ci-cd-github.mdx +99 -0
- package/docs/articles/custom-ci-cd-gitlab.mdx +79 -0
- package/docs/articles/custom-ci-cd.mdx +82 -0
- package/docs/articles/custom-code-patterns.md +418 -0
- package/docs/articles/custom-domains.mdx +258 -0
- package/docs/articles/custom-logging-example.mdx +139 -0
- package/docs/articles/ddos-protection.mdx +138 -0
- package/docs/articles/development-options.mdx +49 -0
- package/docs/articles/environment-variables.mdx +134 -0
- package/docs/articles/environments.mdx +143 -0
- package/docs/articles/fastly-zuplo-host-setup.mdx +41 -0
- package/docs/articles/github-deployment-testing.mdx +101 -0
- package/docs/articles/gke-with-upstream-auth-policy.mdx +192 -0
- package/docs/articles/graphql-security.mdx +180 -0
- package/docs/articles/handling-form-data.mdx +61 -0
- package/docs/articles/health-checks.mdx +109 -0
- package/docs/articles/hosting-options.mdx +70 -0
- package/docs/articles/lazy-load-configuration-into-cache.mdx +92 -0
- package/docs/articles/limits.mdx +98 -0
- package/docs/articles/local-development-debugging.mdx +44 -0
- package/docs/articles/local-development-env-variables.mdx +23 -0
- package/docs/articles/local-development-installing-packages.mdx +23 -0
- package/docs/articles/local-development-routes-designer.mdx +27 -0
- package/docs/articles/local-development-services.mdx +40 -0
- package/docs/articles/local-development-troubleshooting.mdx +56 -0
- package/docs/articles/local-development.mdx +81 -0
- package/docs/articles/log-plugin-aws-cloudwatch.mdx +83 -0
- package/docs/articles/log-plugin-datadog.mdx +84 -0
- package/docs/articles/log-plugin-dynatrace.mdx +75 -0
- package/docs/articles/log-plugin-gcp.mdx +75 -0
- package/docs/articles/log-plugin-loki.mdx +136 -0
- package/docs/articles/log-plugin-new-relic.mdx +84 -0
- package/docs/articles/log-plugin-splunk.mdx +104 -0
- package/docs/articles/log-plugin-sumo.mdx +73 -0
- package/docs/articles/log-plugin-vmware-log-insight.mdx +154 -0
- package/docs/articles/log-request-response-data.mdx +398 -0
- package/docs/articles/logging.mdx +115 -0
- package/docs/articles/manual-mcp-oauth-testing.mdx +193 -0
- package/docs/articles/mcp-quickstart.mdx +135 -0
- package/docs/articles/metrics-plugins.mdx +371 -0
- package/docs/articles/migrate-from-apigee.md +408 -0
- package/docs/articles/migrate-from-aws-api-gateway.md +248 -0
- package/docs/articles/migrate-from-azure-apim.md +292 -0
- package/docs/articles/migrate-from-kong.md +300 -0
- package/docs/articles/migration-overview.md +81 -0
- package/docs/articles/monetization/api-access.mdx +69 -0
- package/docs/articles/monetization/billing-models.md +520 -0
- package/docs/articles/monetization/developer-portal.md +167 -0
- package/docs/articles/monetization/features.mdx +98 -0
- package/docs/articles/monetization/index.mdx +113 -0
- package/docs/articles/monetization/meters.mdx +135 -0
- package/docs/articles/monetization/monetization-policy.md +314 -0
- package/docs/articles/monetization/plan-examples.mdx +366 -0
- package/docs/articles/monetization/plans.mdx +266 -0
- package/docs/articles/monetization/pricing-models.mdx +225 -0
- package/docs/articles/monetization/private-plans.md +154 -0
- package/docs/articles/monetization/quickstart.md +355 -0
- package/docs/articles/monetization/rate-cards.mdx +171 -0
- package/docs/articles/monetization/stripe-integration.md +195 -0
- package/docs/articles/monetization/subscription-lifecycle.md +298 -0
- package/docs/articles/monetization/tax-collection.md +166 -0
- package/docs/articles/monetization/troubleshooting.md +272 -0
- package/docs/articles/monetization-custom.mdx +71 -0
- package/docs/articles/monetization-integrations.mdx +104 -0
- package/docs/articles/monitoring-your-gateway.mdx +53 -0
- package/docs/articles/monorepo-deployment.mdx +350 -0
- package/docs/articles/multiple-auth-policies.mdx +81 -0
- package/docs/articles/non-standard-ports.mdx +30 -0
- package/docs/articles/oauth-authentication.mdx +54 -0
- package/docs/articles/openapi-server-urls.mdx +60 -0
- package/docs/articles/openapi.mdx +130 -0
- package/docs/articles/opentelemetry.mdx +250 -0
- package/docs/articles/per-user-rate-limits-using-db.mdx +112 -0
- package/docs/articles/performance-testing.mdx +304 -0
- package/docs/articles/plugin-akamai-api-security.mdx +76 -0
- package/docs/articles/plugin-azure-blob.mdx +73 -0
- package/docs/articles/plugin-azure-event-hubs.mdx +64 -0
- package/docs/articles/plugin-hydrolix-traffic-peak.mdx +147 -0
- package/docs/articles/policies.mdx +33 -0
- package/docs/articles/rename-or-move-project.mdx +39 -0
- package/docs/articles/rick-and-morty-api-developer-portal-example.mdx +23 -0
- package/docs/articles/routing.mdx +193 -0
- package/docs/articles/s3-signed-url-uploads.mdx +521 -0
- package/docs/articles/secure-tunnel.mdx +84 -0
- package/docs/articles/securing-backend-mtls.mdx +268 -0
- package/docs/articles/securing-your-backend.mdx +148 -0
- package/docs/articles/security.mdx +105 -0
- package/docs/articles/sharing-code-across-projects.mdx +412 -0
- package/docs/articles/source-control-setup-azure.mdx +13 -0
- package/docs/articles/source-control-setup-bitbucket.mdx +43 -0
- package/docs/articles/source-control-setup-github.mdx +172 -0
- package/docs/articles/source-control-setup-gitlab.mdx +12 -0
- package/docs/articles/source-control.mdx +80 -0
- package/docs/articles/step-1-setup-basic-gateway-local.mdx +136 -0
- package/docs/articles/step-1-setup-basic-gateway.mdx +118 -0
- package/docs/articles/step-2-add-rate-limiting-local.mdx +126 -0
- package/docs/articles/step-2-add-rate-limiting.mdx +82 -0
- package/docs/articles/step-3-add-api-key-auth-local.mdx +199 -0
- package/docs/articles/step-3-add-api-key-auth.mdx +166 -0
- package/docs/articles/step-4-deploying-to-the-edge.mdx +220 -0
- package/docs/articles/step-5-dynamic-rate-limiting.mdx +167 -0
- package/docs/articles/support.mdx +144 -0
- package/docs/articles/terraform.mdx +114 -0
- package/docs/articles/testing-graphql.mdx +34 -0
- package/docs/articles/testing.mdx +522 -0
- package/docs/articles/troubleshooting-slow-responses.mdx +301 -0
- package/docs/articles/troubleshooting.md +302 -0
- package/docs/articles/tsconfig.mdx +105 -0
- package/docs/articles/tunnel-setup.mdx +195 -0
- package/docs/articles/tunnel-troubleshooting.mdx +50 -0
- package/docs/articles/update-zup-in-github-action.mdx +110 -0
- package/docs/articles/use-openapi-extension-data.mdx +79 -0
- package/docs/articles/users/multifactor-authentication.mdx +64 -0
- package/docs/articles/users/profile.mdx +13 -0
- package/docs/articles/versioning-on-zuplo.mdx +89 -0
- package/docs/articles/waf-ddos-akamai.md +133 -0
- package/docs/articles/waf-ddos-aws-waf-shield.mdx +85 -0
- package/docs/articles/waf-ddos-fastly.mdx +251 -0
- package/docs/articles/waf-ddos.mdx +140 -0
- package/docs/articles/zuplo-waf.mdx +156 -0
- package/docs/ask.mdx +3 -0
- package/docs/cli/authentication.mdx +56 -0
- package/docs/cli/connectivity.mdx +38 -0
- package/docs/cli/create-zuplo-api.mdx +80 -0
- package/docs/cli/delete.mdx +79 -0
- package/docs/cli/deploy.mdx +156 -0
- package/docs/cli/deploy.partial.mdx +46 -0
- package/docs/cli/dev.mdx +115 -0
- package/docs/cli/docs.mdx +66 -0
- package/docs/cli/editor.mdx +50 -0
- package/docs/cli/global-options.mdx +19 -0
- package/docs/cli/init.mdx +74 -0
- package/docs/cli/link.mdx +74 -0
- package/docs/cli/list.mdx +55 -0
- package/docs/cli/mtls-certificate-create.mdx +94 -0
- package/docs/cli/mtls-certificate-delete.mdx +55 -0
- package/docs/cli/mtls-certificate-describe.mdx +55 -0
- package/docs/cli/mtls-certificate-disable.mdx +55 -0
- package/docs/cli/mtls-certificate-list.mdx +47 -0
- package/docs/cli/mtls-certificate-update.mdx +72 -0
- package/docs/cli/openapi-convert.mdx +111 -0
- package/docs/cli/openapi-merge.mdx +138 -0
- package/docs/cli/openapi-merge.partial.mdx +29 -0
- package/docs/cli/openapi-overlay.mdx +123 -0
- package/docs/cli/overview.mdx +78 -0
- package/docs/cli/project-create.mdx +43 -0
- package/docs/cli/source-migrate.mdx +18 -0
- package/docs/cli/source-upgrade.mdx +41 -0
- package/docs/cli/test.mdx +70 -0
- package/docs/cli/test.partial.mdx +7 -0
- package/docs/cli/tunnel-create.mdx +53 -0
- package/docs/cli/tunnel-create.partial.mdx +9 -0
- package/docs/cli/tunnel-delete.mdx +35 -0
- package/docs/cli/tunnel-delete.partial.mdx +9 -0
- package/docs/cli/tunnel-describe.mdx +45 -0
- package/docs/cli/tunnel-describe.partial.mdx +5 -0
- package/docs/cli/tunnel-list.mdx +35 -0
- package/docs/cli/tunnel-list.partial.mdx +9 -0
- package/docs/cli/tunnel-rate-token.partial.mdx +9 -0
- package/docs/cli/tunnel-rotate-token.mdx +39 -0
- package/docs/cli/tunnel-services-describe.mdx +45 -0
- package/docs/cli/tunnel-services-describe.partial.mdx +9 -0
- package/docs/cli/tunnel-services-update.mdx +48 -0
- package/docs/cli/variable-create.mdx +91 -0
- package/docs/cli/variable-create.partial.mdx +5 -0
- package/docs/cli/variable-update.mdx +75 -0
- package/docs/cli/variable-update.partial.mdx +5 -0
- package/docs/concepts/api-keys.md +146 -0
- package/docs/concepts/authentication.mdx +109 -0
- package/docs/concepts/how-zuplo-works.mdx +120 -0
- package/docs/concepts/project-structure.mdx +174 -0
- package/docs/concepts/rate-limiting.md +246 -0
- package/docs/concepts/request-lifecycle.mdx +56 -0
- package/docs/concepts/source-control-and-deployment.mdx +229 -0
- package/docs/conferences/conference-prize-terms.mdx +80 -0
- package/docs/dedicated/akamai/ai-powered-applications.mdx +223 -0
- package/docs/dedicated/akamai/architecture.mdx +280 -0
- package/docs/dedicated/akamai/caching.mdx +212 -0
- package/docs/dedicated/akamai/cdn.mdx +156 -0
- package/docs/dedicated/architecture.mdx +208 -0
- package/docs/dedicated/custom-domains.mdx +31 -0
- package/docs/dedicated/federated-gateways.mdx +80 -0
- package/docs/dedicated/networking.mdx +69 -0
- package/docs/dedicated/overview.mdx +80 -0
- package/docs/dedicated/source-control.mdx +63 -0
- package/docs/dev-portal/dev-portal-create-consumer-on-auth.mdx +134 -0
- package/docs/dev-portal/introduction.mdx +65 -0
- package/docs/dev-portal/local-development.mdx +72 -0
- package/docs/dev-portal/migration.mdx +526 -0
- package/docs/dev-portal/node-modules.mdx +45 -0
- package/docs/dev-portal/updating.mdx +28 -0
- package/docs/dev-portal/zudoku/components/alert.mdx +130 -0
- package/docs/dev-portal/zudoku/components/badge.mdx +70 -0
- package/docs/dev-portal/zudoku/components/button.mdx +132 -0
- package/docs/dev-portal/zudoku/components/callout.mdx +112 -0
- package/docs/dev-portal/zudoku/components/card.mdx +104 -0
- package/docs/dev-portal/zudoku/components/checkbox.mdx +72 -0
- package/docs/dev-portal/zudoku/components/client-only.mdx +79 -0
- package/docs/dev-portal/zudoku/components/code-tabs.mdx +179 -0
- package/docs/dev-portal/zudoku/components/dialog.mdx +167 -0
- package/docs/dev-portal/zudoku/components/head.mdx +199 -0
- package/docs/dev-portal/zudoku/components/icons.mdx +27 -0
- package/docs/dev-portal/zudoku/components/input.mdx +96 -0
- package/docs/dev-portal/zudoku/components/label.mdx +86 -0
- package/docs/dev-portal/zudoku/components/link.mdx +242 -0
- package/docs/dev-portal/zudoku/components/markdown.mdx +151 -0
- package/docs/dev-portal/zudoku/components/mermaid.mdx +81 -0
- package/docs/dev-portal/zudoku/components/playground.mdx +87 -0
- package/docs/dev-portal/zudoku/components/secret.mdx +78 -0
- package/docs/dev-portal/zudoku/components/select.mdx +176 -0
- package/docs/dev-portal/zudoku/components/shadcn.mdx +73 -0
- package/docs/dev-portal/zudoku/components/slider.mdx +108 -0
- package/docs/dev-portal/zudoku/components/slot.mdx +119 -0
- package/docs/dev-portal/zudoku/components/stepper.mdx +138 -0
- package/docs/dev-portal/zudoku/components/switch.mdx +96 -0
- package/docs/dev-portal/zudoku/components/syntax-highlight.mdx +602 -0
- package/docs/dev-portal/zudoku/components/textarea.mdx +78 -0
- package/docs/dev-portal/zudoku/components/tooltip.mdx +195 -0
- package/docs/dev-portal/zudoku/components/typography.mdx +61 -0
- package/docs/dev-portal/zudoku/configuration/ai-assistants.md +64 -0
- package/docs/dev-portal/zudoku/configuration/api-catalog.md +108 -0
- package/docs/dev-portal/zudoku/configuration/api-reference.md +397 -0
- package/docs/dev-portal/zudoku/configuration/authentication-auth0.md +173 -0
- package/docs/dev-portal/zudoku/configuration/authentication-azure-ad.md +238 -0
- package/docs/dev-portal/zudoku/configuration/authentication-clerk.md +110 -0
- package/docs/dev-portal/zudoku/configuration/authentication-firebase.md +61 -0
- package/docs/dev-portal/zudoku/configuration/authentication-pingfederate.md +136 -0
- package/docs/dev-portal/zudoku/configuration/authentication-supabase.md +225 -0
- package/docs/dev-portal/zudoku/configuration/authentication.md +199 -0
- package/docs/dev-portal/zudoku/configuration/build-configuration.mdx +147 -0
- package/docs/dev-portal/zudoku/configuration/docs.md +282 -0
- package/docs/dev-portal/zudoku/configuration/footer.mdx +214 -0
- package/docs/dev-portal/zudoku/configuration/llms.md +89 -0
- package/docs/dev-portal/zudoku/configuration/navigation.mdx +408 -0
- package/docs/dev-portal/zudoku/configuration/overview.md +380 -0
- package/docs/dev-portal/zudoku/configuration/protected-routes.md +149 -0
- package/docs/dev-portal/zudoku/configuration/search.md +169 -0
- package/docs/dev-portal/zudoku/configuration/sentry.mdx +44 -0
- package/docs/dev-portal/zudoku/configuration/site.md +124 -0
- package/docs/dev-portal/zudoku/configuration/slots.mdx +124 -0
- package/docs/dev-portal/zudoku/configuration/vite-config.md +18 -0
- package/docs/dev-portal/zudoku/custom-plugins.md +287 -0
- package/docs/dev-portal/zudoku/customization/colors-theme.mdx +275 -0
- package/docs/dev-portal/zudoku/customization/fonts.md +110 -0
- package/docs/dev-portal/zudoku/extending/events.md +124 -0
- package/docs/dev-portal/zudoku/guides/custom-pages.md +106 -0
- package/docs/dev-portal/zudoku/guides/environment-variables.md +99 -0
- package/docs/dev-portal/zudoku/guides/mermaid.mdx +70 -0
- package/docs/dev-portal/zudoku/guides/navigation-migration.md +87 -0
- package/docs/dev-portal/zudoku/guides/navigation-rules.mdx +197 -0
- package/docs/dev-portal/zudoku/guides/processors.mdx +234 -0
- package/docs/dev-portal/zudoku/guides/static-files.md +55 -0
- package/docs/dev-portal/zudoku/guides/transforming-examples.md +156 -0
- package/docs/dev-portal/zudoku/guides/using-multiple-apis.md +87 -0
- package/docs/dev-portal/zudoku/markdown/admonitions.md +128 -0
- package/docs/dev-portal/zudoku/markdown/code-blocks.md +196 -0
- package/docs/dev-portal/zudoku/markdown/frontmatter.md +172 -0
- package/docs/dev-portal/zudoku/markdown/mdx.md +68 -0
- package/docs/dev-portal/zudoku/markdown/overview.md +275 -0
- package/docs/dev-portal/zudoku/plugins.md +5 -0
- package/docs/dev-portal/zudoku/writing.mdx +72 -0
- package/docs/errors/bad-request.mdx +39 -0
- package/docs/errors/build-error.mdx +45 -0
- package/docs/errors/fatal-project-error.mdx +39 -0
- package/docs/errors/gateway-timeout.mdx +33 -0
- package/docs/errors/get-head-body-error.mdx +41 -0
- package/docs/errors/main-mod-error.mdx +40 -0
- package/docs/errors/no-project-set.mdx +41 -0
- package/docs/errors/not-found.mdx +43 -0
- package/docs/errors/rate-limit-exceeded.mdx +31 -0
- package/docs/errors/schema-validation-failed.mdx +51 -0
- package/docs/errors/system-configuration-error.mdx +44 -0
- package/docs/errors/unauthorized.mdx +50 -0
- package/docs/errors/unknown-error.mdx +42 -0
- package/docs/errors.mdx +14 -0
- package/docs/guides/canary-routing-for-employees.mdx +385 -0
- package/docs/guides/geolocation-backend-routing.mdx +404 -0
- package/docs/guides/modify-openapi-paths.mdx +371 -0
- package/docs/guides/openapi-overlays.mdx +492 -0
- package/docs/guides/overview.mdx +12 -0
- package/docs/guides/user-based-backend-routing.mdx +437 -0
- package/docs/handlers/aws-lambda.mdx +201 -0
- package/docs/handlers/custom-handler.mdx +112 -0
- package/docs/handlers/legacy-dev-portal-handler.mdx +135 -0
- package/docs/handlers/mcp-server.mdx +730 -0
- package/docs/handlers/openapi.mdx +78 -0
- package/docs/handlers/redirect.mdx +115 -0
- package/docs/handlers/system-handlers.mdx +41 -0
- package/docs/handlers/url-forward.mdx +204 -0
- package/docs/handlers/url-rewrite.mdx +224 -0
- package/docs/handlers/websocket-handler.mdx +154 -0
- package/docs/home.mdx +6 -0
- package/docs/managed-edge/overview.md +78 -0
- package/docs/mcp-server/configuration-migration-guide.mdx +344 -0
- package/docs/mcp-server/custom-tools.mdx +487 -0
- package/docs/mcp-server/graphql.mdx +241 -0
- package/docs/mcp-server/introduction.mdx +122 -0
- package/docs/mcp-server/openai-apps-sdk.mdx +160 -0
- package/docs/mcp-server/prompts.mdx +283 -0
- package/docs/mcp-server/resources.mdx +288 -0
- package/docs/mcp-server/testing.mdx +53 -0
- package/docs/mcp-server/tools.mdx +306 -0
- package/docs/policies/_index.md +92 -0
- package/docs/policies/ab-test-inbound/intro.md +8 -0
- package/docs/policies/ab-test-inbound/policy.ts +14 -0
- package/docs/policies/ab-test-inbound/schema.json +27 -0
- package/docs/policies/ab-test-outbound/intro.md +8 -0
- package/docs/policies/ab-test-outbound/policy.ts +26 -0
- package/docs/policies/ab-test-outbound/schema.json +27 -0
- package/docs/policies/acl-policy-inbound/intro.md +5 -0
- package/docs/policies/acl-policy-inbound/policy.ts +32 -0
- package/docs/policies/acl-policy-inbound/schema.json +52 -0
- package/docs/policies/akamai-ai-firewall/schema.json +98 -0
- package/docs/policies/amberflo-metering-inbound/doc.md +183 -0
- package/docs/policies/amberflo-metering-inbound/intro.md +20 -0
- package/docs/policies/amberflo-metering-inbound/schema.json +108 -0
- package/docs/policies/api-key-inbound/doc.md +77 -0
- package/docs/policies/api-key-inbound/intro.md +30 -0
- package/docs/policies/api-key-inbound/schema.json +84 -0
- package/docs/policies/archive-request-aws-s3-inbound/intro.md +4 -0
- package/docs/policies/archive-request-aws-s3-inbound/policy.ts +58 -0
- package/docs/policies/archive-request-aws-s3-inbound/schema.json +68 -0
- package/docs/policies/archive-request-azure-storage-inbound/doc.md +31 -0
- package/docs/policies/archive-request-azure-storage-inbound/intro.md +4 -0
- package/docs/policies/archive-request-azure-storage-inbound/policy.ts +54 -0
- package/docs/policies/archive-request-azure-storage-inbound/schema.json +53 -0
- package/docs/policies/archive-request-gcp-storage-inbound/doc.md +63 -0
- package/docs/policies/archive-request-gcp-storage-inbound/intro.md +4 -0
- package/docs/policies/archive-request-gcp-storage-inbound/policy.ts +68 -0
- package/docs/policies/archive-request-gcp-storage-inbound/schema.json +47 -0
- package/docs/policies/archive-response-aws-s3-outbound/intro.md +2 -0
- package/docs/policies/archive-response-aws-s3-outbound/policy.ts +59 -0
- package/docs/policies/archive-response-aws-s3-outbound/schema.json +68 -0
- package/docs/policies/archive-response-azure-storage-outbound/doc.md +31 -0
- package/docs/policies/archive-response-azure-storage-outbound/intro.md +3 -0
- package/docs/policies/archive-response-azure-storage-outbound/policy.ts +54 -0
- package/docs/policies/archive-response-azure-storage-outbound/schema.json +53 -0
- package/docs/policies/audit-log-inbound/doc.md +78 -0
- package/docs/policies/audit-log-inbound/intro.md +10 -0
- package/docs/policies/audit-log-inbound/schema.json +81 -0
- package/docs/policies/auth0-jwt-auth-inbound/doc.md +125 -0
- package/docs/policies/auth0-jwt-auth-inbound/intro.md +17 -0
- package/docs/policies/auth0-jwt-auth-inbound/schema.json +74 -0
- package/docs/policies/authzen-inbound/doc.md +24 -0
- package/docs/policies/authzen-inbound/intro.md +31 -0
- package/docs/policies/authzen-inbound/schema.json +126 -0
- package/docs/policies/axiomatics-authz-inbound/doc.md +144 -0
- package/docs/policies/axiomatics-authz-inbound/intro.md +11 -0
- package/docs/policies/axiomatics-authz-inbound/schema.json +161 -0
- package/docs/policies/basic-auth-inbound/intro.md +9 -0
- package/docs/policies/basic-auth-inbound/schema.json +99 -0
- package/docs/policies/bot-detection-inbound/intro.md +4 -0
- package/docs/policies/bot-detection-inbound/schema.json +56 -0
- package/docs/policies/brownout-inbound/doc.md +55 -0
- package/docs/policies/brownout-inbound/intro.md +12 -0
- package/docs/policies/brownout-inbound/schema.json +115 -0
- package/docs/policies/caching-inbound/doc.md +209 -0
- package/docs/policies/caching-inbound/intro.md +23 -0
- package/docs/policies/caching-inbound/schema.json +98 -0
- package/docs/policies/change-method-inbound/schema.json +56 -0
- package/docs/policies/clear-headers-inbound/schema.json +59 -0
- package/docs/policies/clear-headers-outbound/schema.json +59 -0
- package/docs/policies/clerk-jwt-auth-inbound/doc.md +85 -0
- package/docs/policies/clerk-jwt-auth-inbound/intro.md +4 -0
- package/docs/policies/clerk-jwt-auth-inbound/schema.json +68 -0
- package/docs/policies/cognito-jwt-auth-inbound/intro.md +7 -0
- package/docs/policies/cognito-jwt-auth-inbound/schema.json +74 -0
- package/docs/policies/comet-opik-tracing-inbound/schema.json +65 -0
- package/docs/policies/complex-rate-limit-inbound/doc.md +20 -0
- package/docs/policies/complex-rate-limit-inbound/intro.md +23 -0
- package/docs/policies/complex-rate-limit-inbound/schema.json +142 -0
- package/docs/policies/composite-inbound/doc.md +69 -0
- package/docs/policies/composite-inbound/intro.md +15 -0
- package/docs/policies/composite-inbound/schema.json +59 -0
- package/docs/policies/composite-outbound/intro.md +6 -0
- package/docs/policies/composite-outbound/schema.json +59 -0
- package/docs/policies/curity-phantom-token-inbound/doc.md +109 -0
- package/docs/policies/curity-phantom-token-inbound/intro.md +3 -0
- package/docs/policies/curity-phantom-token-inbound/schema.json +68 -0
- package/docs/policies/custom-code-inbound/doc.md +267 -0
- package/docs/policies/custom-code-inbound/intro.md +2 -0
- package/docs/policies/custom-code-inbound/schema.json +48 -0
- package/docs/policies/custom-code-outbound/doc.md +235 -0
- package/docs/policies/custom-code-outbound/intro.md +2 -0
- package/docs/policies/custom-code-outbound/schema.json +43 -0
- package/docs/policies/firebase-jwt-inbound/intro.md +6 -0
- package/docs/policies/firebase-jwt-inbound/schema.json +68 -0
- package/docs/policies/formdata-to-json-inbound/schema.json +60 -0
- package/docs/policies/galileo-tracing-inbound/schema.json +65 -0
- package/docs/policies/geo-filter-inbound/doc.md +33 -0
- package/docs/policies/geo-filter-inbound/schema.json +108 -0
- package/docs/policies/graphql-complexity-limit-inbound/doc.md +48 -0
- package/docs/policies/graphql-complexity-limit-inbound/intro.md +2 -0
- package/docs/policies/graphql-complexity-limit-inbound/schema.json +90 -0
- package/docs/policies/graphql-disable-introspection-inbound/doc.md +66 -0
- package/docs/policies/graphql-disable-introspection-inbound/intro.md +15 -0
- package/docs/policies/graphql-disable-introspection-inbound/schema.json +48 -0
- package/docs/policies/graphql-introspection-filter-outbound/doc.md +148 -0
- package/docs/policies/graphql-introspection-filter-outbound/schema.json +79 -0
- package/docs/policies/hmac-auth-inbound/doc.md +30 -0
- package/docs/policies/hmac-auth-inbound/intro.md +10 -0
- package/docs/policies/hmac-auth-inbound/policy.ts +70 -0
- package/docs/policies/hmac-auth-inbound/schema.json +53 -0
- package/docs/policies/http-deprecation-outbound/doc.md +73 -0
- package/docs/policies/http-deprecation-outbound/schema.json +83 -0
- package/docs/policies/ip-restriction-inbound/intro.md +8 -0
- package/docs/policies/ip-restriction-inbound/policy.ts +40 -0
- package/docs/policies/ip-restriction-inbound/schema.json +58 -0
- package/docs/policies/jwt-scopes-inbound/schema.json +59 -0
- package/docs/policies/ldap-auth-inbound/schema.json +56 -0
- package/docs/policies/mock-api-inbound/schema.json +72 -0
- package/docs/policies/moesif-inbound/doc.md +44 -0
- package/docs/policies/moesif-inbound/intro.md +6 -0
- package/docs/policies/moesif-inbound/schema.json +68 -0
- package/docs/policies/monetization-inbound/doc.md +87 -0
- package/docs/policies/monetization-inbound/intro.md +6 -0
- package/docs/policies/monetization-inbound/schema.json +102 -0
- package/docs/policies/mtls-auth-inbound/intro.md +6 -0
- package/docs/policies/mtls-auth-inbound/schema.json +68 -0
- package/docs/policies/okta-fga-authz-inbound/doc.md +181 -0
- package/docs/policies/okta-fga-authz-inbound/intro.md +20 -0
- package/docs/policies/okta-fga-authz-inbound/schema.json +104 -0
- package/docs/policies/okta-jwt-auth-inbound/intro.md +7 -0
- package/docs/policies/okta-jwt-auth-inbound/schema.json +74 -0
- package/docs/policies/open-id-jwt-auth-inbound/doc.md +58 -0
- package/docs/policies/open-id-jwt-auth-inbound/intro.md +30 -0
- package/docs/policies/open-id-jwt-auth-inbound/schema.json +128 -0
- package/docs/policies/openfga-authz-inbound/doc.md +207 -0
- package/docs/policies/openfga-authz-inbound/intro.md +17 -0
- package/docs/policies/openfga-authz-inbound/schema.json +191 -0
- package/docs/policies/openmeter-inbound/doc.md +163 -0
- package/docs/policies/openmeter-inbound/intro.md +18 -0
- package/docs/policies/openmeter-inbound/schema.json +183 -0
- package/docs/policies/prompt-injection-outbound/doc.md +106 -0
- package/docs/policies/prompt-injection-outbound/intro.md +4 -0
- package/docs/policies/prompt-injection-outbound/schema.json +74 -0
- package/docs/policies/propel-auth-jwt-inbound/doc.md +88 -0
- package/docs/policies/propel-auth-jwt-inbound/intro.md +4 -0
- package/docs/policies/propel-auth-jwt-inbound/schema.json +74 -0
- package/docs/policies/query-param-to-header-inbound/doc.md +70 -0
- package/docs/policies/query-param-to-header-inbound/intro.md +5 -0
- package/docs/policies/query-param-to-header-inbound/schema.json +74 -0
- package/docs/policies/quota-inbound/doc.md +235 -0
- package/docs/policies/quota-inbound/intro.md +7 -0
- package/docs/policies/quota-inbound/schema.json +133 -0
- package/docs/policies/rate-limit-inbound/doc.md +78 -0
- package/docs/policies/rate-limit-inbound/intro.md +30 -0
- package/docs/policies/rate-limit-inbound/schema.json +134 -0
- package/docs/policies/rbac-policy-inbound/intro.md +3 -0
- package/docs/policies/rbac-policy-inbound/policy.ts +42 -0
- package/docs/policies/rbac-policy-inbound/schema.json +52 -0
- package/docs/policies/readme-metrics-inbound/doc.md +1 -0
- package/docs/policies/readme-metrics-inbound/intro.md +3 -0
- package/docs/policies/readme-metrics-inbound/schema.json +84 -0
- package/docs/policies/remove-headers-inbound/schema.json +59 -0
- package/docs/policies/remove-headers-outbound/schema.json +59 -0
- package/docs/policies/remove-query-params-inbound/schema.json +59 -0
- package/docs/policies/replace-string-outbound/schema.json +69 -0
- package/docs/policies/request-size-limit-inbound/schema.json +60 -0
- package/docs/policies/request-validation-inbound/doc.md +72 -0
- package/docs/policies/request-validation-inbound/intro.md +24 -0
- package/docs/policies/request-validation-inbound/schema.json +98 -0
- package/docs/policies/require-origin-inbound/intro.md +12 -0
- package/docs/policies/require-origin-inbound/schema.json +65 -0
- package/docs/policies/secret-masking-outbound/doc.md +41 -0
- package/docs/policies/secret-masking-outbound/intro.md +13 -0
- package/docs/policies/secret-masking-outbound/schema.json +65 -0
- package/docs/policies/semantic-cache-inbound/doc.md +63 -0
- package/docs/policies/semantic-cache-inbound/intro.md +4 -0
- package/docs/policies/semantic-cache-inbound/schema.json +179 -0
- package/docs/policies/set-body-inbound/intro.md +7 -0
- package/docs/policies/set-body-inbound/schema.json +56 -0
- package/docs/policies/set-headers-inbound/doc.md +41 -0
- package/docs/policies/set-headers-inbound/intro.md +2 -0
- package/docs/policies/set-headers-inbound/schema.json +83 -0
- package/docs/policies/set-headers-outbound/schema.json +83 -0
- package/docs/policies/set-query-params-inbound/schema.json +83 -0
- package/docs/policies/set-status-outbound/schema.json +62 -0
- package/docs/policies/sleep-inbound/schema.json +56 -0
- package/docs/policies/stripe-webhook-verification-inbound/intro.md +2 -0
- package/docs/policies/stripe-webhook-verification-inbound/schema.json +60 -0
- package/docs/policies/supabase-jwt-auth-inbound/doc.md +29 -0
- package/docs/policies/supabase-jwt-auth-inbound/intro.md +12 -0
- package/docs/policies/supabase-jwt-auth-inbound/schema.json +86 -0
- package/docs/policies/transform-body-inbound/intro.md +8 -0
- package/docs/policies/transform-body-inbound/policy.ts +16 -0
- package/docs/policies/transform-body-inbound/schema.json +27 -0
- package/docs/policies/transform-body-outbound/intro.md +8 -0
- package/docs/policies/transform-body-outbound/policy.ts +19 -0
- package/docs/policies/transform-body-outbound/schema.json +27 -0
- package/docs/policies/upstream-azure-ad-service-auth-inbound/doc.md +82 -0
- package/docs/policies/upstream-azure-ad-service-auth-inbound/intro.md +20 -0
- package/docs/policies/upstream-azure-ad-service-auth-inbound/schema.json +84 -0
- package/docs/policies/upstream-firebase-admin-auth-inbound/intro.md +10 -0
- package/docs/policies/upstream-firebase-admin-auth-inbound/schema.json +68 -0
- package/docs/policies/upstream-firebase-user-auth-inbound/intro.md +2 -0
- package/docs/policies/upstream-firebase-user-auth-inbound/schema.json +113 -0
- package/docs/policies/upstream-gcp-federated-auth-inbound/doc.md +139 -0
- package/docs/policies/upstream-gcp-federated-auth-inbound/intro.md +21 -0
- package/docs/policies/upstream-gcp-federated-auth-inbound/schema.json +96 -0
- package/docs/policies/upstream-gcp-jwt-inbound/intro.md +10 -0
- package/docs/policies/upstream-gcp-jwt-inbound/schema.json +62 -0
- package/docs/policies/upstream-gcp-service-auth-inbound/doc.md +132 -0
- package/docs/policies/upstream-gcp-service-auth-inbound/intro.md +25 -0
- package/docs/policies/upstream-gcp-service-auth-inbound/schema.json +95 -0
- package/docs/policies/upstream-zuplo-jwt-auth-inbound/doc.md +213 -0
- package/docs/policies/upstream-zuplo-jwt-auth-inbound/intro.md +16 -0
- package/docs/policies/upstream-zuplo-jwt-auth-inbound/schema.json +101 -0
- package/docs/policies/validate-json-schema-inbound/doc.md +129 -0
- package/docs/policies/validate-json-schema-inbound/intro.md +7 -0
- package/docs/policies/validate-json-schema-inbound/schema.json +56 -0
- package/docs/policies/web-bot-auth-inbound/doc.md +104 -0
- package/docs/policies/web-bot-auth-inbound/intro.md +16 -0
- package/docs/policies/web-bot-auth-inbound/schema.json +76 -0
- package/docs/policies/xml-to-json-outbound/doc.md +71 -0
- package/docs/policies/xml-to-json-outbound/intro.md +4 -0
- package/docs/policies/xml-to-json-outbound/schema.json +117 -0
- package/docs/programmable-api/audit-log.mdx +74 -0
- package/docs/programmable-api/background-dispatcher.mdx +124 -0
- package/docs/programmable-api/background-loader.mdx +104 -0
- package/docs/programmable-api/cache.mdx +186 -0
- package/docs/programmable-api/compatibility-dates.mdx +201 -0
- package/docs/programmable-api/console-logging.mdx +48 -0
- package/docs/programmable-api/context-data.mdx +127 -0
- package/docs/programmable-api/custom-cors-policy.mdx +64 -0
- package/docs/programmable-api/environment.mdx +328 -0
- package/docs/programmable-api/hooks.mdx +569 -0
- package/docs/programmable-api/http-problems.mdx +385 -0
- package/docs/programmable-api/jwt-service-plugin.mdx +420 -0
- package/docs/programmable-api/logger.mdx +223 -0
- package/docs/programmable-api/memory-zone-read-through-cache.mdx +96 -0
- package/docs/programmable-api/node-modules.mdx +67 -0
- package/docs/programmable-api/not-found-handler.mdx +47 -0
- package/docs/programmable-api/oauth-protected-resource-plugin.mdx +46 -0
- package/docs/programmable-api/overview.mdx +213 -0
- package/docs/programmable-api/problem-response-formatter.mdx +183 -0
- package/docs/programmable-api/request-user.mdx +289 -0
- package/docs/programmable-api/reusing-code.mdx +26 -0
- package/docs/programmable-api/route-raw.mdx +55 -0
- package/docs/programmable-api/runtime-behaviors.mdx +25 -0
- package/docs/programmable-api/runtime-errors.mdx +246 -0
- package/docs/programmable-api/runtime-extensions.mdx +340 -0
- package/docs/programmable-api/safely-clone-a-request-or-response.mdx +57 -0
- package/docs/programmable-api/streaming-zone-cache.mdx +155 -0
- package/docs/programmable-api/web-crypto-apis.mdx +219 -0
- package/docs/programmable-api/web-standard-apis.mdx +109 -0
- package/docs/programmable-api/zone-cache.mdx +131 -0
- package/docs/programmable-api/zp-body-removed.mdx +32 -0
- package/docs/programmable-api/zuplo-context.mdx +414 -0
- package/docs/programmable-api/zuplo-id-token.mdx +90 -0
- package/docs/programmable-api/zuplo-json.mdx +91 -0
- package/docs/programmable-api/zuplo-request.mdx +200 -0
- package/docs/sample-apis.mdx +78 -0
- package/docs/self-hosted/overview.md +60 -0
- package/package.json +6 -5
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Route to Backends Based on User Identity
|
|
3
|
+
sidebar_label: User-Based Backend Routing
|
|
4
|
+
description:
|
|
5
|
+
Learn how to create a Zuplo policy that routes requests to different backends
|
|
6
|
+
based on API key metadata or JWT claims for multi-tenant and environment
|
|
7
|
+
isolation scenarios.
|
|
8
|
+
tags:
|
|
9
|
+
- backends
|
|
10
|
+
- custom-code
|
|
11
|
+
- authentication
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
This guide explains how to create a Zuplo policy that routes requests to
|
|
15
|
+
different backend URLs based on user identity information, such as API key
|
|
16
|
+
metadata or JWT custom claims.
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Many API providers need to route different users to different backend
|
|
21
|
+
environments. Common scenarios include:
|
|
22
|
+
|
|
23
|
+
- **Environment separation** - Route users to sandbox or production backends
|
|
24
|
+
based on their API key, similar to how Stripe uses test and live API keys
|
|
25
|
+
- **Customer isolation** - Route each customer to their own isolated backend
|
|
26
|
+
environment for data privacy or compliance requirements
|
|
27
|
+
- **Hybrid multi-tenant** - Route some customers to dedicated backends while
|
|
28
|
+
others use a shared multi-tenant environment
|
|
29
|
+
|
|
30
|
+
Zuplo's programmable gateway makes these routing patterns simple to implement
|
|
31
|
+
with custom policies that read user data from API keys or JWT tokens.
|
|
32
|
+
|
|
33
|
+
## How It Works
|
|
34
|
+
|
|
35
|
+
When a request is authenticated using Zuplo's
|
|
36
|
+
[API Key Authentication](../policies/api-key-inbound.mdx) or any
|
|
37
|
+
[JWT Authentication](../policies/open-id-jwt-auth-inbound.mdx) policy, user
|
|
38
|
+
information becomes available on `request.user`:
|
|
39
|
+
|
|
40
|
+
- `request.user.sub` - The unique identifier for the user
|
|
41
|
+
- `request.user.data` - Additional metadata (API key metadata or JWT claims)
|
|
42
|
+
|
|
43
|
+
Your custom policy reads this data and determines the appropriate backend URL
|
|
44
|
+
for the request.
|
|
45
|
+
|
|
46
|
+
## Use Case 1: Environment-Based Routing (Stripe-Style Keys)
|
|
47
|
+
|
|
48
|
+
Companies like Stripe use separate API keys for sandbox and production
|
|
49
|
+
environments. Users get a test key (`sk_test_...`) for development and a live
|
|
50
|
+
key (`sk_live_...`) for production, both hitting the same API endpoint.
|
|
51
|
+
|
|
52
|
+
You can implement this pattern by storing an `environment` property in your API
|
|
53
|
+
key metadata:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// modules/environment-routing.ts
|
|
57
|
+
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
|
|
58
|
+
|
|
59
|
+
export default async function policy(
|
|
60
|
+
request: ZuploRequest,
|
|
61
|
+
context: ZuploContext,
|
|
62
|
+
) {
|
|
63
|
+
// Get the environment from API key metadata or JWT claims
|
|
64
|
+
const userEnvironment = request.user?.data?.environment;
|
|
65
|
+
|
|
66
|
+
if (userEnvironment === "sandbox") {
|
|
67
|
+
context.custom.downstreamUrl = environment.SANDBOX_BACKEND_URL;
|
|
68
|
+
context.log.info("Routing to sandbox environment");
|
|
69
|
+
} else if (userEnvironment === "production") {
|
|
70
|
+
context.custom.downstreamUrl = environment.PRODUCTION_BACKEND_URL;
|
|
71
|
+
context.log.info("Routing to production environment");
|
|
72
|
+
} else {
|
|
73
|
+
throw new Error("Unknown environment in user data");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return request;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When creating API keys in the Zuplo portal, set the metadata to include the
|
|
81
|
+
environment:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"environment": "sandbox"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Or for production keys:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"environment": "production"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Use Case 2: Customer-Specific Backend Routing
|
|
98
|
+
|
|
99
|
+
For B2B APIs where each customer needs their own isolated backend (for
|
|
100
|
+
compliance, data residency, or white-label deployments), you can route based on
|
|
101
|
+
customer-specific configuration.
|
|
102
|
+
|
|
103
|
+
### Using a Configuration File
|
|
104
|
+
|
|
105
|
+
For smaller deployments, store routing configuration in a JSON file:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
// config/customers.json
|
|
109
|
+
[
|
|
110
|
+
{
|
|
111
|
+
"customerId": "acme-corp",
|
|
112
|
+
"environmentName": "acme",
|
|
113
|
+
"backendUrl": "https://acme.tenants.example.com"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"customerId": "wayne-ent",
|
|
117
|
+
"environmentName": "wayne",
|
|
118
|
+
"backendUrl": "https://wayne.tenants.example.com"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"customerId": "stark-ind",
|
|
122
|
+
"environmentName": "stark",
|
|
123
|
+
"backendUrl": "https://stark.tenants.example.com"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Create a policy that reads the customer ID from user data and looks up the
|
|
129
|
+
backend:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// modules/customer-routing.ts
|
|
133
|
+
import { HttpProblems, ZuploContext, ZuploRequest } from "@zuplo/runtime";
|
|
134
|
+
import customers from "../config/customers.json";
|
|
135
|
+
|
|
136
|
+
interface CustomerConfig {
|
|
137
|
+
customerId: string;
|
|
138
|
+
environmentName: string;
|
|
139
|
+
backendUrl: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default async function policy(
|
|
143
|
+
request: ZuploRequest,
|
|
144
|
+
context: ZuploContext,
|
|
145
|
+
) {
|
|
146
|
+
// Get customer ID from API key metadata or JWT claims
|
|
147
|
+
const customerId = request.user?.data?.customerId;
|
|
148
|
+
|
|
149
|
+
if (!customerId) {
|
|
150
|
+
context.log.warn("No customer ID found in user data");
|
|
151
|
+
return HttpProblems.unauthorized(request, context, {
|
|
152
|
+
detail: "Customer identification required",
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Find the customer's routing configuration
|
|
157
|
+
const customer = (customers as CustomerConfig[]).find(
|
|
158
|
+
(c) => c.customerId === customerId,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (!customer) {
|
|
162
|
+
context.log.error(`Customer configuration not found: ${customerId}`);
|
|
163
|
+
return HttpProblems.forbidden(request, context, {
|
|
164
|
+
detail: "Customer not configured",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Set the downstream URL for use by the handler
|
|
169
|
+
context.custom.downstreamUrl = customer.backendUrl;
|
|
170
|
+
|
|
171
|
+
context.log.info({
|
|
172
|
+
message: "Routing request to customer backend",
|
|
173
|
+
customerId,
|
|
174
|
+
backend: customer.backendUrl,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return request;
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Using BackgroundLoader for Dynamic Configuration
|
|
182
|
+
|
|
183
|
+
For production deployments with frequently changing customer configurations, use
|
|
184
|
+
the [BackgroundLoader](../programmable-api/background-loader.mdx) to fetch
|
|
185
|
+
routing data from an external service while minimizing latency:
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// modules/customer-routing-dynamic.ts
|
|
189
|
+
import {
|
|
190
|
+
BackgroundLoader,
|
|
191
|
+
HttpProblems,
|
|
192
|
+
ZuploContext,
|
|
193
|
+
ZuploRequest,
|
|
194
|
+
environment,
|
|
195
|
+
} from "@zuplo/runtime";
|
|
196
|
+
|
|
197
|
+
interface CustomerConfig {
|
|
198
|
+
customerId: string;
|
|
199
|
+
backendUrl: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Create the background loader at module level
|
|
203
|
+
const customerConfigLoader = new BackgroundLoader<CustomerConfig[]>(
|
|
204
|
+
async () => {
|
|
205
|
+
const response = await fetch(environment.CUSTOMER_CONFIG_API_URL, {
|
|
206
|
+
headers: {
|
|
207
|
+
Authorization: `Bearer ${environment.CONFIG_API_TOKEN}`,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
if (!response.ok) {
|
|
212
|
+
throw new Error(`Failed to load customer config: ${response.status}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return response.json();
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
ttlSeconds: 300, // Cache for 5 minutes
|
|
219
|
+
loaderTimeoutSeconds: 10,
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
export default async function policy(
|
|
224
|
+
request: ZuploRequest,
|
|
225
|
+
context: ZuploContext,
|
|
226
|
+
) {
|
|
227
|
+
const customerId = request.user?.data?.customerId;
|
|
228
|
+
|
|
229
|
+
if (!customerId) {
|
|
230
|
+
return HttpProblems.unauthorized(request, context, {
|
|
231
|
+
detail: "Customer identification required",
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Load customer configurations (returns cached data immediately if available)
|
|
236
|
+
const customers = await customerConfigLoader.get("customers");
|
|
237
|
+
const customer = customers.find((c) => c.customerId === customerId);
|
|
238
|
+
|
|
239
|
+
if (!customer) {
|
|
240
|
+
context.log.error(`Customer not found: ${customerId}`);
|
|
241
|
+
return HttpProblems.forbidden(request, context, {
|
|
242
|
+
detail: "Customer not configured",
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
context.custom.downstreamUrl = customer.backendUrl;
|
|
247
|
+
|
|
248
|
+
return request;
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The `BackgroundLoader` provides significant advantages for production use:
|
|
253
|
+
|
|
254
|
+
- Returns cached data immediately when available
|
|
255
|
+
- Refreshes data in the background without blocking requests
|
|
256
|
+
- Only blocks when the cache is empty or expired
|
|
257
|
+
- Ensures only one request per key is active at any time
|
|
258
|
+
|
|
259
|
+
## Use Case 3: Hybrid Multi-Tenant Routing
|
|
260
|
+
|
|
261
|
+
Some architectures use a mix of dedicated and shared backends. Premium customers
|
|
262
|
+
get isolated environments while others use a shared multi-tenant backend:
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// modules/hybrid-routing.ts
|
|
266
|
+
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
|
|
267
|
+
import dedicatedCustomers from "../config/dedicated-customers.json";
|
|
268
|
+
|
|
269
|
+
interface DedicatedCustomer {
|
|
270
|
+
customerId: string;
|
|
271
|
+
backendUrl: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export default async function policy(
|
|
275
|
+
request: ZuploRequest,
|
|
276
|
+
context: ZuploContext,
|
|
277
|
+
) {
|
|
278
|
+
const customerId = request.user?.data?.customerId;
|
|
279
|
+
|
|
280
|
+
// Check if this customer has a dedicated backend
|
|
281
|
+
const dedicatedConfig = (dedicatedCustomers as DedicatedCustomer[]).find(
|
|
282
|
+
(c) => c.customerId === customerId,
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
if (dedicatedConfig) {
|
|
286
|
+
// Route to dedicated backend
|
|
287
|
+
context.custom.downstreamUrl = dedicatedConfig.backendUrl;
|
|
288
|
+
context.log.info({
|
|
289
|
+
message: "Routing to dedicated backend",
|
|
290
|
+
customerId,
|
|
291
|
+
type: "dedicated",
|
|
292
|
+
});
|
|
293
|
+
} else {
|
|
294
|
+
// Route to shared multi-tenant backend
|
|
295
|
+
context.custom.downstreamUrl = environment.MULTI_TENANT_BACKEND_URL;
|
|
296
|
+
context.log.info({
|
|
297
|
+
message: "Routing to shared backend",
|
|
298
|
+
customerId: customerId ?? "anonymous",
|
|
299
|
+
type: "shared",
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return request;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Using JWT Claims for Routing
|
|
308
|
+
|
|
309
|
+
If you're using JWT authentication instead of API keys, the same patterns apply.
|
|
310
|
+
JWT custom claims are available on `request.user.data`:
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// modules/jwt-based-routing.ts
|
|
314
|
+
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
|
|
315
|
+
|
|
316
|
+
export default async function policy(
|
|
317
|
+
request: ZuploRequest,
|
|
318
|
+
context: ZuploContext,
|
|
319
|
+
) {
|
|
320
|
+
// Access JWT custom claims
|
|
321
|
+
const tenantId = request.user?.data?.tenant_id;
|
|
322
|
+
const tier = request.user?.data?.subscription_tier;
|
|
323
|
+
|
|
324
|
+
if (tier === "enterprise" && tenantId) {
|
|
325
|
+
// Enterprise customers with tenant ID get dedicated backends
|
|
326
|
+
context.custom.downstreamUrl = `https://${tenantId}.api.example.com`;
|
|
327
|
+
} else {
|
|
328
|
+
// Standard tier uses shared infrastructure
|
|
329
|
+
context.custom.downstreamUrl = environment.SHARED_BACKEND_URL;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return request;
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Wiring Up the Policy
|
|
337
|
+
|
|
338
|
+
### Policy Configuration
|
|
339
|
+
|
|
340
|
+
Add your routing policy to `config/policies.json`:
|
|
341
|
+
|
|
342
|
+
```json
|
|
343
|
+
{
|
|
344
|
+
"name": "customer-routing",
|
|
345
|
+
"policyType": "custom-code-inbound",
|
|
346
|
+
"handler": {
|
|
347
|
+
"export": "default",
|
|
348
|
+
"module": "$import(./modules/customer-routing)"
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Route Configuration
|
|
354
|
+
|
|
355
|
+
Add the policy to your routes, placing it after authentication:
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
{
|
|
359
|
+
"paths": {
|
|
360
|
+
"/api/v1/{+path}": {
|
|
361
|
+
"x-zuplo-path": {
|
|
362
|
+
"pathMode": "open-api"
|
|
363
|
+
},
|
|
364
|
+
"get": {
|
|
365
|
+
"x-zuplo-route": {
|
|
366
|
+
"corsPolicy": "anything-goes",
|
|
367
|
+
"handler": {
|
|
368
|
+
"export": "urlRewriteHandler",
|
|
369
|
+
"module": "$import(@zuplo/runtime)",
|
|
370
|
+
"options": {
|
|
371
|
+
"rewritePattern": "${context.custom.downstreamUrl}/${params.path}"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"policies": {
|
|
375
|
+
"inbound": ["api-key-auth", "customer-routing"]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
The policy sets `context.custom.downstreamUrl`, and the URL Rewrite handler uses
|
|
385
|
+
that value to forward the request to the correct backend.
|
|
386
|
+
|
|
387
|
+
## Benefits of This Approach
|
|
388
|
+
|
|
389
|
+
### Single Entry Point
|
|
390
|
+
|
|
391
|
+
Customers access your API through one consistent URL regardless of their backend
|
|
392
|
+
environment. This simplifies documentation, SDKs, and client implementations.
|
|
393
|
+
|
|
394
|
+
### Centralized Policy Enforcement
|
|
395
|
+
|
|
396
|
+
Authentication, rate limiting, and other policies are enforced uniformly at the
|
|
397
|
+
gateway before requests reach any backend. This ensures consistent security and
|
|
398
|
+
compliance across all environments.
|
|
399
|
+
|
|
400
|
+
### Flexible Routing Logic
|
|
401
|
+
|
|
402
|
+
Zuplo's custom code capability means you can implement any routing logic you
|
|
403
|
+
need:
|
|
404
|
+
|
|
405
|
+
- Route based on geographic regions
|
|
406
|
+
- Implement A/B testing with traffic splitting
|
|
407
|
+
- Handle failover between primary and backup backends
|
|
408
|
+
- Combine multiple factors (user tier + geography + load balancing)
|
|
409
|
+
|
|
410
|
+
### Operational Simplicity
|
|
411
|
+
|
|
412
|
+
Manage routing configuration centrally rather than maintaining separate gateway
|
|
413
|
+
deployments for each environment or customer.
|
|
414
|
+
|
|
415
|
+
## Best Practices
|
|
416
|
+
|
|
417
|
+
1. **Always validate user data** - Check that required fields exist before using
|
|
418
|
+
them for routing decisions
|
|
419
|
+
2. **Provide sensible defaults** - Have a fallback for cases where routing
|
|
420
|
+
configuration is missing
|
|
421
|
+
3. **Log routing decisions** - Include customer ID and selected backend in logs
|
|
422
|
+
for debugging
|
|
423
|
+
4. **Use environment variables** - Store backend URLs in environment variables
|
|
424
|
+
rather than hardcoding them
|
|
425
|
+
5. **Consider caching** - For dynamic configurations, use `BackgroundLoader` or
|
|
426
|
+
`MemoryZoneReadThroughCache` to minimize latency
|
|
427
|
+
|
|
428
|
+
## Next Steps
|
|
429
|
+
|
|
430
|
+
- Learn about [custom policies](../policies/custom-code-inbound.mdx)
|
|
431
|
+
- Explore the [BackgroundLoader](../programmable-api/background-loader.mdx) for
|
|
432
|
+
dynamic configuration
|
|
433
|
+
- Set up [API Key Authentication](../policies/api-key-inbound.mdx) with metadata
|
|
434
|
+
- Configure [JWT Authentication](../policies/open-id-jwt-auth-inbound.mdx) with
|
|
435
|
+
custom claims
|
|
436
|
+
- Review [environment variables](../articles/environment-variables.mdx) for
|
|
437
|
+
managing backend URLs
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AWS Lambda Handler
|
|
3
|
+
sidebar_label: AWS Lambda
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The AWS Lambda handler is used to send requests to AWS Lambda. This handler can
|
|
7
|
+
be used as an alternative to AWS API Gateway when exposing Lambda functions as
|
|
8
|
+
an API or HTTP endpoint.
|
|
9
|
+
|
|
10
|
+
:::note
|
|
11
|
+
|
|
12
|
+
Many customers use the Zuplo AWS Lambda handler as a replacement for AWS API
|
|
13
|
+
Gateway, however it should not be considered a complete fire-and-forget
|
|
14
|
+
replacement. Some features, such as error handling behavior, may differ. Test
|
|
15
|
+
your API to ensure the behavior meets your expectations, especially in migration
|
|
16
|
+
scenarios.
|
|
17
|
+
|
|
18
|
+
:::
|
|
19
|
+
|
|
20
|
+
## IAM Permissions
|
|
21
|
+
|
|
22
|
+
Zuplo requires access to execute your Lambda function. Create an
|
|
23
|
+
[IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html)
|
|
24
|
+
and grant that account only the permission needed to invoke the Lambda function.
|
|
25
|
+
The IAM user does not require console access, only API access. The IAM user
|
|
26
|
+
requires the
|
|
27
|
+
[**AWSLambdaRole**](https://docs.aws.amazon.com/lambda/latest/dg/access-control-identity-based.html)
|
|
28
|
+
role. This role can be scoped to only the specific Lambda functions required.
|
|
29
|
+
|
|
30
|
+
## Setup via Portal
|
|
31
|
+
|
|
32
|
+
To set up the AWS Lambda handler in the portal UI, select the AWS Lambda handler
|
|
33
|
+
on any route.
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
Configure the properties for your AWS Lambda function.
|
|
38
|
+
|
|
39
|
+
:::warning
|
|
40
|
+
|
|
41
|
+
Don't add the AWS Secure Access Key directly in the `routes.oas.json` file.
|
|
42
|
+
Instead use environment variables like `$env(AWS_SECURE_ACCESS_KEY)`
|
|
43
|
+
|
|
44
|
+
:::
|
|
45
|
+
|
|
46
|
+
## Setup via routes.oas.json
|
|
47
|
+
|
|
48
|
+
Set up the AWS Lambda handler by editing the `routes.oas.json` file directly.
|
|
49
|
+
Configure the `handler` property on any route's `x-zuplo-route` property.
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"handler": {
|
|
54
|
+
"export": "awsLambdaHandler",
|
|
55
|
+
"module": "$import(@zuplo/runtime)",
|
|
56
|
+
"options": {
|
|
57
|
+
"accessKeyId": "$env(AWS_ACCESS_KEY_ID)",
|
|
58
|
+
"functionName": "demo-post-1",
|
|
59
|
+
"region": "us-east-2",
|
|
60
|
+
"secretAccessKey": "$env(AWS_SECURE_ACCESS_KEY)"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Options
|
|
67
|
+
|
|
68
|
+
The AWS Lambda handler accepts the following options:
|
|
69
|
+
|
|
70
|
+
- **`accessKeyId`** (required): The AWS access key ID for authentication. Use an
|
|
71
|
+
environment variable reference like `$env(AWS_ACCESS_KEY_ID)`.
|
|
72
|
+
- **`secretAccessKey`** (required): The AWS secret access key. Use an
|
|
73
|
+
environment variable reference like `$env(AWS_SECURE_ACCESS_KEY)`.
|
|
74
|
+
- **`functionName`** (required): The name of the AWS Lambda function to invoke.
|
|
75
|
+
- **`region`** (required): The AWS region where the Lambda function runs (e.g.,
|
|
76
|
+
`us-east-2`).
|
|
77
|
+
- **`binaryMediaTypes`** (optional): An array of content types to convert to
|
|
78
|
+
base64-encoded strings when sending to the Lambda function.
|
|
79
|
+
- **`returnAmazonTraceIdHeader`** (optional): When `true`, includes the
|
|
80
|
+
`X-Amzn-Trace-Id` header in the response. Default: `false`.
|
|
81
|
+
- **`useLambdaProxyIntegration`** (optional): When `true`, sends the request
|
|
82
|
+
using the AWS API Gateway event format. Default: `false`.
|
|
83
|
+
- **`payloadFormatVersion`** (optional): The API Gateway payload format version.
|
|
84
|
+
Set to `"1.0"` or `"2.0"`. Only applies when `useLambdaProxyIntegration` is
|
|
85
|
+
`true`.
|
|
86
|
+
- **`useAwsResourcePathStyle`** (optional): When `true`, converts Zuplo-style
|
|
87
|
+
path parameters (`:param`) to AWS-style (`{param}`) in `resourcePath`.
|
|
88
|
+
Default: `false`.
|
|
89
|
+
|
|
90
|
+
## Binary Media Types
|
|
91
|
+
|
|
92
|
+
For content types, the `binaryMediaTypes` option allows specifying which content
|
|
93
|
+
types get converted to base64 encoded strings when sent as the body to the AWS
|
|
94
|
+
Lambda function. See
|
|
95
|
+
[AWS docs for details](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html).
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"handler": {
|
|
100
|
+
"export": "awsLambdaHandler",
|
|
101
|
+
"module": "$import(@zuplo/runtime)",
|
|
102
|
+
"options": {
|
|
103
|
+
"accessKeyId": "$env(AWS_ACCESS_KEY_ID)",
|
|
104
|
+
"functionName": "demo-post-1",
|
|
105
|
+
"region": "us-east-2",
|
|
106
|
+
"secretAccessKey": "$env(AWS_SECURE_ACCESS_KEY)",
|
|
107
|
+
"binaryMediaTypes": ["image/png", "application/pdf"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## X-Amzn-Trace-Id Header
|
|
114
|
+
|
|
115
|
+
For the purposes of troubleshooting and tracing, it can be useful to return the
|
|
116
|
+
`X-Amzn-Trace-Id` header in the response. This can help correlate AWS Lambda
|
|
117
|
+
events or errors with Zuplo requests/responses. This header is disabled by
|
|
118
|
+
default, but it can be enabled by setting the configuration option
|
|
119
|
+
`returnAmazonTraceIdHeader` to `true`.
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"handler": {
|
|
124
|
+
"export": "awsLambdaHandler",
|
|
125
|
+
"module": "$import(@zuplo/runtime)",
|
|
126
|
+
"options": {
|
|
127
|
+
"accessKeyId": "$env(AWS_ACCESS_KEY_ID)",
|
|
128
|
+
"functionName": "demo-post-1",
|
|
129
|
+
"region": "us-east-2",
|
|
130
|
+
"secretAccessKey": "$env(AWS_SECURE_ACCESS_KEY)",
|
|
131
|
+
"returnAmazonTraceIdHeader": true
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Compressed Body Content
|
|
138
|
+
|
|
139
|
+
:::note
|
|
140
|
+
|
|
141
|
+
This is provided as a work-around for certain Lambda + AWS API Gateway migration
|
|
142
|
+
scenarios and isn't recommended to use on new deployments
|
|
143
|
+
|
|
144
|
+
:::
|
|
145
|
+
|
|
146
|
+
The Zuplo handler supports `gzip` and `deflate` compression of the content of
|
|
147
|
+
the AWS Lambda response `body` property. In order to instruct the Zuplo handler
|
|
148
|
+
to decompress the body content add a property on the outgoing event called
|
|
149
|
+
`bodyEncoding` and set the value to `gzip` or `deflate`.
|
|
150
|
+
|
|
151
|
+
The response event would look like this:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"isBase64Encoded": true,
|
|
156
|
+
"bodyEncoding": "gzip",
|
|
157
|
+
"body": "COMPRESSSED AND BASE64 ENCODED BODY",
|
|
158
|
+
"...": "other properties..."
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## API Gateway Compatibility
|
|
163
|
+
|
|
164
|
+
The AWS Lambda handler can also call Lambda functions that were built for API
|
|
165
|
+
Gateway.
|
|
166
|
+
|
|
167
|
+
Setting `options.useLambdaProxyIntegration` to `true` will tell the handler to
|
|
168
|
+
call the function with the event format that matches with AWS API Gateway. You
|
|
169
|
+
can also choose between the payload format by setting
|
|
170
|
+
`options.payloadFormatVersion` to either `1.0` or `2.0`.
|
|
171
|
+
|
|
172
|
+
The value for `requestContext.resourcePath` sent to the AWS Lambda function is
|
|
173
|
+
the parameterized path of the route. Zuplo uses path-to-regex style paths (for
|
|
174
|
+
example `/my/route/:param1`) instead of OpenAPI style paths, for example,
|
|
175
|
+
`/my/route/{param1}` for routes. By default, the value of `resourcePath` is the
|
|
176
|
+
Zuplo route value. Setting `useAwsResourcePathStyle` to `true` will convert the
|
|
177
|
+
value to the AWS format.
|
|
178
|
+
|
|
179
|
+
For more details about the AWS payload formats see
|
|
180
|
+
[AWS's documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html).
|
|
181
|
+
|
|
182
|
+
Below is an example lambda handler configured for proxy integration with payload
|
|
183
|
+
format 2.0.
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"handler": {
|
|
188
|
+
"export": "awsLambdaHandler",
|
|
189
|
+
"module": "$import(@zuplo/runtime)",
|
|
190
|
+
"options": {
|
|
191
|
+
"accessKeyId": "$env(AWS_ACCESS_KEY_ID)",
|
|
192
|
+
"functionName": "demo-post-1",
|
|
193
|
+
"region": "us-east-2",
|
|
194
|
+
"secretAccessKey": "$env(AWS_SECURE_ACCESS_KEY)",
|
|
195
|
+
"useLambdaProxyIntegration": true,
|
|
196
|
+
"payloadFormatVersion": "2.0",
|
|
197
|
+
"useAwsResourcePathStyle": true
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|