-
Notifications
You must be signed in to change notification settings - Fork 26
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 regular expression matching to --output-http-rewrite-url #127
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import ( | |
"testing" | ||
) | ||
|
||
func TestUrlRewriteMap(t *testing.T) { | ||
func TestUrlRewriteMap_1(t *testing.T) { | ||
var url string | ||
|
||
rewrites := UrlRewriteMap{} | ||
|
@@ -15,7 +15,6 @@ func TestUrlRewriteMap(t *testing.T) { | |
} | ||
|
||
url = "/abc" | ||
|
||
if rewrites.Rewrite(url) == url { | ||
t.Error("Request url should have been rewritten, wasn't") | ||
} | ||
|
@@ -25,3 +24,24 @@ func TestUrlRewriteMap(t *testing.T) { | |
t.Error("Request url should not have been rewritten, was") | ||
} | ||
} | ||
|
||
func TestUrlRewriteMap_2(t *testing.T) { | ||
var url string | ||
|
||
rewrites := UrlRewriteMap{} | ||
|
||
err := rewrites.Set("/v1/user/([^\\/]+)/ping:/v2/user/$1/ping") | ||
if err != nil { | ||
t.Error("Should not error on /v1/user/([^\\/]+)/ping:/v2/user/$1/ping") | ||
} | ||
|
||
url = "/v1/user/joe/ping" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls also add tests that explicitly checks if rewrites.Rewrite(url) == /v2/user/joe/ping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pushed. does that work for you? 2014-10-28 18:24 GMT+01:00 Leonid Bugaev notifications@github.com:
|
||
if rewrites.Rewrite(url) == url { | ||
t.Error("Request url should have been rewritten, wasn't") | ||
} | ||
|
||
url = "/v1/user/ping" | ||
if rewrites.Rewrite(url) != url { | ||
t.Error("Request url should not have been rewritten, was") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not know about ReplaceAllString function, love go standard lib! :)