add file example

This commit is contained in:
Umputun
2021-04-10 13:10:32 -05:00
parent c970c176a9
commit 8135e99d4d
3 changed files with 30 additions and 0 deletions

13
examples/file/Makefile Normal file
View File

@@ -0,0 +1,13 @@
run: install
whoami -port 8081 -name=svc1 &
whoami -port 8082 -name=svc2 &
whoami -port 8083 -name=svc3 &
../../dist/reproxy --file.enabled --file.name=reproxy.yml
pkill -9 whoami
kill:
pkill -9 whoami
install:
cd ../../app && CGO_ENABLED=0 go build -o ../dist/reproxy
cd /tmp && go install github.com/traefik/whoami@latest

12
examples/file/README.md Normal file
View File

@@ -0,0 +1,12 @@
# Example of a file provider
To run it do `make run` and try to hit it, for example
- `curl localhost:8080/api/svc1/aaaaa`
- `curl localhost:8080/api/svc1`
- `curl localhost:8080/api/svc2/something`
- `curl localhost:8080/api/svc3/something`
- `curl 127.0.0.1:8080/api/svc3/something`
for health check try - `curl localhost:8080/health`
In order to kill all services run `make kill`

View File

@@ -0,0 +1,5 @@
default:
- {route: "^/api/svc1/(.*)", dest: "http://127.0.0.1:8081/api/$1","ping": "http://127.0.0.1:8081/health"}
- {route: "/api/svc2", dest: "http://127.0.0.1:8082/api", "ping": "http://127.0.0.1:8082/health"}
localhost:
- {route: "^/api/svc3/(.*)", dest: "http://localhost:8083/$1","ping": "http://127.0.0.1:8083/health"}