Korean | README_ko |
---|
Asynchronous API Gateway with Spring boot 2.1, Servlet 4, jetty 9 client
The Gateway is a network gateway created to provide a single access point for real-time web based protocol elevation that supports load balancing, clustering, and several validations. It is designed to make the best performance to deliver open API.
Moon API Gateway offers a powerful, yet lightweight feature.
There are required settings to run moon-api-gateway. You do not need to use initialization with the management API.
- Please set the global application first in application.yaml
moon:
service:
ip-acl-enable: false
cluster:
enable: false
sync-interval: 300000
repository-type: rdb
proxy-timeout: 20000
api-ratelimit:
enable: false
jedis-client:
host: '127.0.0.1'
port: 6379
timeout: 1000
database: 0
- Please set the initial application registration in application-apps.yaml
- (These settings are optional)
init-apps:
init-enable: true
apps:
-
app-id: 0
app-name: TestApp
api-key: 1000-1000-1000-1000
app-minutely-ratelimit: 2000
app-daily-ratelimit: 10000
app-service-contract: [1, 2, 3]
app-ip-acl: ['192.168.0.1', '127.0.0.1']
-
app-id: 1
app-name: BestApp
api-key: e3938427-1e27-3a37-a854-0ac5a40d84a8
app-minutely-ratelimit: 1000
app-daily-ratelimit: 50000
app-service-contract: [1, 2]
app-ip-acl: ['127.0.0.1']
- Set up service and API specification configurations in application-apis.yml
- The API Gateway obtains Service and API information through the APIExposeSpecLoader.
api-spec:
init-enable: true
services:
-
service-id: 1
service-name: stackoverflow
service-minutely-capacity: 10000
service-daily-capacity: 240000
service-path: /stackoverflow
outbound-service-host: api.stackexchange.com
apis:
-
api-id: 101
api-name: getInfo
protocol: http, https
inbound-method: get
outbound-method: get
inbound-url: /2.2/question/:first
outbound-url: /2.2/questions
header: page, votes
header-required: ""
query-param: version, site
query-param-required: site
-
api-id: 202
api-name: getQuestions
protocol: https
inbound-method: put
outbound-method: put
inbound-url: /2.2/question/:first
outbound-url: /2.2/questions
header: page, votes
header-required: ""
query-param: version, site
query-param-required: site
-
service-id: 2
service-name: stackoverflow2
service-minutely-capacity: 5000
service-daily-capacity: 100000
service-path: /another
outbound-service-host: api.stackexchange.com
apis:
-
api-id: 201
api-name: transformTest
protocol: http, https
method: get
inbound-url: /2.2/haha/question/:site
outbound-url: /:page/:site
header: page, votes
header-required: ""
query-param: version, site
query-param-required: site
transform:
page: [header, param_path]
site: [param_path, header]
-
service-id: '03'
service-name: service3
service-minutely-capacity: 5000
service-daily-capacity: 100000
service-path: /service3
outbound-service-host: api.stackexchange.com
only-pass-request-without-transform: true
Moon-api-gateway supports the following protocol and method.
Moon API Gateway supports clusters. Each node synchronizes API, APP, IP Whitelist and App Key (= API Key) information in near real time. Cluster nodes also work together to calculate the correct API Ratelimiting, Service Capacity.
The Management API helps manage a single gateway or cluster group.
SERVICE Management
APP Management
API Management
Service And API Expose Specification for stackoverflow
service-id: '01'
service-name: stackoverflow
service-minutely-capacity: 10000
service-daily-capacity: 240000
service-path: /stackoverflow
outbound-service-host: api.stackexchange.com
apis:
-
api-id: '0101'
api-name: getInfo
protocol: http, https
inbound-method: get
outbound-method: get
inbound-url: /2.2/question/:first
outbound-url: /2.2/questions
header: page, votes
header-required: ""
query-param: version, site
query-param-required: site
./docker run -p 8080:8080 longcoding/moon-api-gateway
// Use curl or rest-client
./curl -X GET -H "Content-type: application/json" -H "apikey: 1000-1000-1000-1000" -H "page: 5" -H "votes: 1" http://localhost:8080/stackoverflow/2.2/question/test?site=stackoverflow
./gradlew test
To set method and scheme.
GET, http
Input URL.
http://localhost:8080/stackoverflow/2.2/question/test
Input URL parameter. ( site is mandatory query parameter )
site = stackoverflow
OR you can input URL like below.
http://localhost:8080/stackoverflow/2.2/question/test?site=stackoverflow
and then input header fields. ( apikey is mandatory header.(or Query Parameter) )
apikey, 1000-1000-1000-1000
page, 5
votes, 1
Execute request and check response code and content.
curl -X GET -H "Content-type: application/json" -H "apikey: 1000-1000-1000-1000" -H "page: 5" -H "votes: 1" http://localhost:8080/stackoverflow/2.2/question/test?site=stackoverflow
For any inquiries, you can reach me at [email protected]
moon-api-gateway is released under the MIT license. See LICENSE for details.