Sign inSign up

xuybin/go-api-gateway

By xuybin

•Updated almost 9 years ago

simple api gateway written by golang from

Image
0

1.0K

xuybin/go-api-gateway repository overview

⁠go-api-gateway

Build Status A simple API gateway written by golang.

Support for authenticate and authorization, and web applications will be protected after the gateway.

in development now.

documents will be wrote later.

⁠ARCH

arch

⁠CONFIGURATION

You could use cli option or environment varibles to config your api gateway

./go-api-gateway --help
Options:

  -h, --help                                display help information
  -c, --*conn[=$GATEWAY_CONN_STR]          *mysql connection str
  -l, --*listen[=$GATEWAY_LS]              *gateway listen host and port
  -r, --*resource[=$GATEWAY_RESOURCE_URL]  *gateway resource url

  • -c --conn GATEWAY_CONN_STR, mysql connection string, format is user:pass@tcp(domain:port)/dbname

  • -l --listen GATEWAY_LS, gateway listen addr, format is host:port, example: 0.0.0.0:1329

  • -r --resource GATEWAY_RESOURCE_URL, gateway protect target, the resource server, could be a api server, format is http://host:port⁠

⁠DOCKER

you could find docker image from here⁠

docker deployment example:

docker run -d --restart=always -p 80:80 -e GATEWAY_CONN_STR='user:pass@tcp(mysql:3306)/auth' -e GATEWAY_RESOURCE_URL='http://api:80' --link mysql_1:mysql --link mysql_api:api --name api_gateway xuybin/go-api-gateway

docker swarm deployment example:

curl -s -L https://raw.githubusercontent.com/xuybin/go-api-gateway/master/docker-compose.yml >docker-compose.yml && docker stack deploy -c docker-compose.yml mystack
docker stack ps mystack
docker stack rm mystack

docker-compose deployment example:

docker-compose up
docker-compose ps
docker-compose rm

⁠DOWNLOAD

You could download the latest build binaries from release page⁠ !

⁠Swagger UI Support

The go-mysql-api support swagger.json and provide swagger.html page

Open /gateway/docs/ to see swagger documents, the interactive documention will be helpful.

And go-api-gateway provide the swagger.json at path /gateway/swagger/

Because of initialization data into casbin_rule table

p  admin  /policy/*	  (GET)|(POST)|(PUT)|(DELETE)|(HEAD)

So register admin first to authorize the operation at /gateway/docs/

Tag summary

Content type

Image

Digest

Size

10.3 MB

Last updated

almost 9 years ago

docker pull xuybin/go-api-gateway