The plugin provides both an unconditional and a conditional proxy directive.
To invoke the proxy in your routes, see this example:
```ruby
route do |r|
# /my
r.on 'my' do
# /my/api
r.on 'api' do
# /my/api/path
r.is 'path' do
# GET /my/api/path
r.get do
r.proxy
end
end
end
end
end
```
The proxy will always be invoked. Headers and body are passed through unmodified in both directions with the exception of `Host` which is rewritten to match the target.
Also provided is a conditional proxy:
```ruby
route do |r|
# /my
r.on 'my' do
# /my/api
r.on 'api' do
# /my/api/path
r.is 'path' do
# GET /my/api/path
r.get do
r.proxy_when(r.env['HTTP_PROXY'] == 'true', probability: 0.5) do
With `proxy_when` the first optional parameter expects a truthy value or a block / lambda that returns a truthy value. This must be equivalent to `true` for the proxying to occur. The optional probability is a float between 0 and 1 indicating the probability that proxying will happen. Both paramters can be used alone or in isolation.