commit | 2f99bd15dcb8c94adadd060d4e746a46990652be | [log] [tgz] |
---|---|---|
author | Cody M. Walker <cmwalker@us.ibm.com> | Wed Oct 12 16:03:39 2016 -0400 |
committer | GitHub Enterprise <noreply@github.ibm.com> | Wed Oct 12 16:03:39 2016 -0400 |
tree | 5040977ca66bdea02758ebccfbb6736b5eea0a88 | |
parent | eb22dec04951b1a0a765b4ad216730828649483c [diff] | |
parent | c18cf617a5b1c5e0a40ce3fab560f59996e4f88a [diff] |
Merge pull request #29 from apimesh/documentation Update README.md
A performant API Gateway based on Openresty and NGINX.
docker run -p 80:80 -p 9000:9000 \ -e REDIS_HOST=<redis_host> \ -e REDIS_PORT=<redis_port> \ -e REDIS_PASS=<redis_pass> \ apicgw/apigateway:latest
This command starts an API Gateway that subscribes to the Redis instance with the specified host and port. The REDIS_PASS
variable is optional and is required only when redis needs authentication.
On startup, the API Gateway looks for pre-existing routes in redis, whose keys are defined as routes:<namespace>:<route>
, and creates nginx conf files associated with those routes. Then, it listens for any route key changes in redis and updates nginx conf files appropriately. These conf files are stored in the running docker container at /etc/api-gateway/managed_confs/<namespace>/<route>.conf
.
The following endpoints are exposed to port 9000.
Create/update and expose a new route on the gateway associated with a namespace and a url-encoded route, with the implementation matching the passed values.
body:
{ "gatewayMethod": *(string) The method that you would like your newly exposed API to listen on. "backendURL": *(string) The fully qualified URL that you would like your invoke operation to target. "backendMethod": (string) The method that you would like the invoke operation to use. If none is supplied, the gatewayMethod will be used. "policies": *(array) A list of policy objects that will be applied during the execution of your route. "security": (object) An optional json object defining security policies (e.g. {"type": "apikey"} ) }
Returns:
{ "managedUrl": (string) The URL at which you can invoke your newly created route. }
Get the specified route and return the managed url.
Returns:
{ "managedUrl": (string) The URL at which you can invoke the route. }
Delete the specified route from redis and delete the corresponding conf file.
Returns:
Route deleted.
This is called automatically on gateway startup. It subscribes to route key changes in redis and creates/updates the necessary nginx conf files.
Add/update an api key for a given route. Alternatively, call PUT /subscriptions/{namespace}/{api-key}
to create an api key for the namespace.
Returns:
Subscription created.
Delete an api key associated with the route. Alternatively, call DELETE /subscriptions/{namespace}/{api-key} to delete an api key associated with the namespace.
Returns:
Subscription deleted.
To build the docker image locally use:
make docker
To Run the Docker image
make docker-run-mgmt REDIS_HOST=<redis_host> REDIS_PORT=<redis_port> REDIS_PASS=<redis_pass>
The main API Gateway process is exposed to port 80
. To test that the Gateway works see its health-check
:
$ curl http://<docker_host_ip>/health-check API-Platform is running!