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 Header proxy policy #1751

Merged
merged 1 commit into from Jul 10, 2017

Conversation

3 participants
@zikes
Contributor

zikes commented Jul 7, 2017

1. What does this change do, exactly?

Add a new proxy policy which routes to upstream based on the hash of a given request header's value.

Example:

proxy {
  policy header My-Header
}

This also changes the Policy registration process to allow policies to receive a single optional string argument.

2. Please link to the relevant issues.

#1463

3. Which documentation changes (if any) need to be made because of this PR?

The new policy would need added at https://caddyserver.com/docs/proxy

4. Checklist

  • I have written tests and verified that they fail without my change
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I am willing to help maintain this change if there are issues with it later
@@ -22,7 +22,7 @@ import (
)

var (
supportedPolicies = make(map[string]func() Policy)
supportedPolicies = make(map[string]func(string) Policy)

This comment has been minimized.

@abiosoft

abiosoft Jul 7, 2017

Collaborator

Or maybe func(args ...string) Policy to make it dynamic in case of any future policy that may require more than one args.

This comment has been minimized.

@zikes

zikes Jul 7, 2017

Contributor

Per @mholt's recommendation in #1463 it's just string, but changing it to ...string would be fairly trivial.

This comment has been minimized.

@mholt

mholt Jul 10, 2017

Owner

This is fine, I'm rewriting this part of the proxy middleware now and will take it into account.

@mholt

mholt approved these changes Jul 10, 2017

This'll work. Thanks for taking care of this, @zikes!

@mholt mholt merged commit 4c700ef into mholt:master Jul 10, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@mholt mholt modified the milestone: 0.10.5 Jul 10, 2017

@zikes

This comment has been minimized.

Contributor

zikes commented Jul 10, 2017

I'll try to submit a PR to caddyserver/website soon to update the documentation for this.

@zikes zikes deleted the zikes:header_policy branch Jul 10, 2017

@mholt

This comment has been minimized.

Owner

mholt commented Jul 10, 2017

Perfect, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment