diff --git a/examples/file/Makefile b/examples/file/Makefile new file mode 100644 index 0000000..e3cf9cc --- /dev/null +++ b/examples/file/Makefile @@ -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 diff --git a/examples/file/README.md b/examples/file/README.md new file mode 100644 index 0000000..576bbc6 --- /dev/null +++ b/examples/file/README.md @@ -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` diff --git a/examples/file/reproxy.yml b/examples/file/reproxy.yml new file mode 100644 index 0000000..da167a0 --- /dev/null +++ b/examples/file/reproxy.yml @@ -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"}