Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add routing constraints #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kieraneglin
Copy link

Related to #29.

We had a case where we needed to proxy requests for the root-level domain, but didn't want to proxy requests for any subdomains. This is the type of scenario this PR looks to address.

To use this, simply pass a lambda to a constraint option on reverse_proxy. This lambda should return a boolean, but any truthy value will work:

reverse_proxy '/test', 'https://example.com', constraint: ->(req) { req.host === 'root-level-domain.com' }

As you can see, there is access to the rack request object within the constraint.

Usage of constraints is entirely optional and should not pose any issues to backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant