From f8977afa485e2993901f78eeee6097254b23e2bf Mon Sep 17 00:00:00 2001 From: udhos Date: Sat, 20 May 2023 23:17:38 -0300 Subject: [PATCH] Add examples. --- README.md | 37 +++++++++++++++++++++++++-- sample/google.yaml | 2 ++ sample/{request.yaml => miniapi.yaml} | 0 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 sample/google.yaml rename sample/{request.yaml => miniapi.yaml} (100%) diff --git a/README.md b/README.md index 0b93cfd..aa652a1 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,39 @@ cd forward ## Usage +Send this request body to `forward`. + +``` +body: put-actual-body-to-forward-here +method: GET +set_headers: + key1: value1 + key2: value2 +url: http://localhost:2000/v1/hello # put full request URL here +``` + +### Example for Google + +``` +# start forward +forward +``` + +``` +# call forward + +$ more sample/google.yaml +url: https://www.google.com/search?q=golang +method: GET + +$ curl --data-binary @sample/google.yaml localhost:8080/forward + +``` + +### Example for miniapi + +Forward to [miniapi](https://github.com/udhos/miniapi). + ``` # start miniapi on port 2000 export ADDR=:2000 @@ -39,14 +72,14 @@ forward ``` # call forward -$ more sample/request.yaml +$ more sample/miniapi.yaml body: aaaaa method: PUT set_headers: a: b url: http://localhost:2000/v1/hello -$ curl --data-binary @sample/request.yaml localhost:8080/forward +$ curl --data-binary @sample/miniapi.yaml localhost:8080/forward {"request":{"headers":{"A":["b"],"Accept-Encoding":["gzip"],"Content-Length":["5"],"User-Agent":["Go-http-client/1.1"],"X-B3-Sampled":["1"],"X-B3-Spanid":["23e1685fce0c9374"],"X-B3-Traceid":["1c8318e574e71c17b61eec3814ede924"]},"method":"PUT","uri":"/v1/hello","host":"localhost:2000","body":"aaaaa","form_query":{},"form_post":{},"parameters":{"param1":"","param2":""}},"message":"ok","status":200,"server_hostname":"ubuntu","server_version":"1.0.5"} ``` diff --git a/sample/google.yaml b/sample/google.yaml new file mode 100644 index 0000000..fdfd358 --- /dev/null +++ b/sample/google.yaml @@ -0,0 +1,2 @@ +url: https://www.google.com/search?q=golang +method: GET diff --git a/sample/request.yaml b/sample/miniapi.yaml similarity index 100% rename from sample/request.yaml rename to sample/miniapi.yaml