Add support for restricting certain urls

This commit is contained in:
Leonid Bugaev
2015-07-08 20:27:35 +05:00
parent 686d7436ae
commit 413f50129f
3 changed files with 23 additions and 11 deletions
+9 -10
View File
@@ -5,16 +5,6 @@ import (
"hash/fnv"
)
type HTTPModifierConfig struct {
urlRegexp HTTPUrlRegexp
urlRewrite UrlRewriteMap
headerFilters HTTPHeaderFilters
headerHashFilters HTTPHeaderHashFilters
headers HTTPHeaders
methods HTTPMethods
}
type HTTPModifier struct {
config *HTTPModifierConfig
}
@@ -47,6 +37,15 @@ func (m *HTTPModifier) Rewrite(payload []byte) (response []byte) {
}
}
if m.config.urlNegativeRegexp.regexp != nil {
host, _, _, _ := proto.Header(payload, []byte("Host"))
fullPath := append(host, proto.Path(payload)...)
if m.config.urlNegativeRegexp.regexp.Match(fullPath) {
return
}
}
if len(m.config.headerFilters) > 0 {
for _, f := range m.config.headerFilters {
value, s, _, _ := proto.Header(payload, f.name)