./gradlew bootRun
See Application.kt for the code related to this example.
Example proxying an image to Wikipedia
See Application.kt for the code related to this example.
Example proxying an image to Wikipedia
See Application.kt for the code related to this example.
curl 'http://localhost:8080/get?&hello=there'
Should proxy to httpbin.com and output the query parameters in the args
element
as well as the headers. Notes the addition of the "Hello"
header:
{
"args": {
"hello": "there"
},
"headers": {
"Accept": "*/*",
"Content-Length": "0",
"Forwarded": "proto=http;host=\"localhost:8080\";for=\"0:0:0:0:0:0:0:1:58106\"",
"Hello": "World",
"Host": "httpbin.org",
"User-Agent": "curl/7.64.1",
"X-Amzn-Trace-Id": "Root=1-60eca8f4-054b3bd44e5e313963920d64",
"X-Forwarded-Host": "localhost:8080"
},
"origin": "0:0:0:0:0:0:0:1, 34.236.252.22",
"url": "https://localhost:8080/get?hello=there"
}
See Application.kt for the code related to this example.
So far all the examples have only shown proxying to a single URL. What if you wanted to proxy to multiple URLs using a common prefix? You can do that because all paths are in AntPathMatcher format
For this example, any path starting with /base64/ is proxied to HTTPBin.
The /base64/{valuee}
endpoint is documented at HTTPBin here.
For example try this.
Both the home page and /tree will redirect to the /tree.jpg image.