apig/README.md

65 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2018-03-15 05:40:43 +00:00
# apig
Just a small experiment in replicating the API gateway pattern for microservices.
2018-03-15 06:30:12 +00:00
## Manifest Format
```
2018-03-15 06:50:23 +00:00
// service name, used in logging and metrics
2018-03-15 06:30:12 +00:00
service printerfacts
2018-03-15 06:50:23 +00:00
// https backend to reverse proxy to
2018-03-15 06:30:12 +00:00
backend https://printerfacts.herokuapp.com
2018-03-15 06:50:23 +00:00
// healthcheck endpoint. This should return 2xx.
2018-03-15 06:30:12 +00:00
health /index.html
2018-03-15 06:50:23 +00:00
// playbook URL for humans to use when responding to downtime
2018-03-15 06:30:12 +00:00
playbook_url https://github.com/Xe/printerfacts/wiki/Playbooks#healthcheck-is-down
2018-03-15 06:50:23 +00:00
// twirp blocks establish HTTP routes for both JSON and Protobuf twirp clients.
2018-03-15 06:30:12 +00:00
twirp (
2018-03-15 06:50:23 +00:00
// use assumptions for this service based on the twirp version in question.
require v5
// public <package> <service> <method>
// This defines a public API call. This also will require the application/json
// or application/protobuf Accept and Content-Type header with a POST verb
// where the path is built from the version assumptions + the twirp metadata.
public us.xeserv.api Printerfacts Fact
// private <scope> <package> <service> <method>
// This defines a private API call scoped to users with the given permission
// for this service. This also will require the application/json or
// application/protobuf Accept and Content-Type header with a POST verb where
// the path is built from the version assumptions + the twirp metadata.
2018-03-15 06:30:12 +00:00
)
```
```
service ponyapi
backend https://ponyapi.apps.xeserv.us
health /newest
2018-03-15 06:50:23 +00:00
// http blocks establish arbitrary http routes. For sanity and hygene reasons,
// all services will have their routes prefixed by the service name. In this
// example, the resulting routes on the API gateway would be `/ponyapi/all`,
// etc.
2018-03-15 06:30:12 +00:00
http (
2018-03-15 06:50:23 +00:00
// public <method> <path>
public GET /
2018-03-15 06:30:12 +00:00
public GET /all
public GET /newest
public GET /last_aired
public GET /season/:snum
public GET /season/:snum/episode/:enum
public GET /random
public GET /search
2018-03-15 06:50:23 +00:00
// private <scope> <method> <path>
private admin GET /_stats
2018-03-15 06:30:12 +00:00
)
```
2018-03-15 06:50:23 +00:00