Koivu is a lightweight API gateway. It has ratelimiting through Redis, API-key authentication and logging. Koivu is a stateless service and can be run locally, in docker or in kubernetes.
Koivu has three configuration files: routes.yaml, api-keys.yaml and redis.yaml.
routes.yaml
port: "8080"
routes:
- name: order
prefix: /api/v1/order
destination: http://localhost:8040/v1/order
authentication: key
ratelimit:
requests: 5
timeframe: second
type: ip
api-keys.yaml
keys:
- value: super-secret-password-here
routes: [order]
redis.yaml
redis:
url: localhost:6379
password: ""
cd /src
go run ./main.go
Refactor the destinations of routes to be docker-container names.
cd /src
Build the image
docker build -t koivu-api-gateway .
Create a docker network
docker network create -d bridge app-network
Run the docker application
docker run -p 8080:8080 --network app-network koivu-api-gateway:latest
Example when running application as a docker container
Remember that the routed applications should be in the docker network!
Available ratelimiting parameters are the following:
- requests:
uint
- timeframe:
second
,minute
,hour
,day
- type:
ip
Available authentication parameters are the following:
- authentication:
key
,none