| # |
| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| |
| server { |
| listen 9000; |
| server_name management_gw; |
| |
| include /etc/api-gateway/conf.d/commons/common-headers.conf; |
| include /etc/api-gateway/conf.d/includes/resolvers.conf; |
| |
| # Log locations with service name |
| lua_socket_log_errors off; |
| access_log /var/log/api-gateway/access.log main; |
| error_log /var/log/api-gateway/management.log debug; |
| |
| location ~ /(?<version>v2)/(?<tenantId>[^/]*)/apis/?(?<api_id>[^/]*)?/?(?<query>[^/]*)? { |
| access_by_lua_block { |
| local ds = require('lib/dataStore') |
| local dataStore = ds.init() |
| local apis = require("management/routes/apis") |
| apis.requestHandler(dataStore) |
| } |
| } |
| |
| location ~ /(?<version>v1)/apis/?(?<api_id>[^/]*)?/?(?<query>[^/]*)? { |
| access_by_lua_block { |
| local apis = require("management/routes/apis") |
| local ds = require('lib/dataStore') |
| local dataStore = ds.init() |
| apis.requestHandler(dataStore) |
| } |
| } |
| |
| location ~ /v1/tenants/?(?<tenant_id>[^/]*)?/?(?<query>[^/]*)? { |
| access_by_lua_block { |
| local tenants = require("management/routes/tenants") |
| local ds = require('lib/dataStore') |
| local dataStore = ds.init() |
| tenants.requestHandler(dataStore) |
| } |
| } |
| |
| location ~ /(?<version>v2)/(?<tenant_id>[^/]*)/subscriptions/?(?<client_id>[^/]*)?/? { |
| access_by_lua_block { |
| local subscriptions = require("management/routes/subscriptions") |
| local ds = require('lib/dataStore') |
| local dataStore = ds.init() |
| subscriptions.requestHandler(dataStore) |
| } |
| } |
| |
| location ~ /(?<version>v1)/subscriptions/? { |
| access_by_lua_block { |
| local subscriptions = require("management/routes/subscriptions") |
| local ds = require('lib/dataStore') |
| local dataStore = ds.init() |
| subscriptions.requestHandler(dataStore) |
| } |
| } |
| |
| location /v1/health-check { |
| access_log off; |
| access_by_lua_block { |
| local requestMethod = ngx.req.get_method() |
| if requestMethod == "GET" then |
| local request = require "lib/request" |
| request.success(200, "Status: Gateway ready.") |
| else |
| ngx.say("Invalid verb") |
| end |
| } |
| } |
| } |