ifthen
This commit is contained in:
@@ -28,6 +28,12 @@ type (
|
|||||||
To string
|
To string
|
||||||
Redir bool
|
Redir bool
|
||||||
BasicAuth string `yaml:"basicAuth"`
|
BasicAuth string `yaml:"basicAuth"`
|
||||||
|
If []IfThen
|
||||||
|
}
|
||||||
|
|
||||||
|
IfThen struct {
|
||||||
|
Headers map[string]string
|
||||||
|
Then Endpoint
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,23 @@ func (c *Config) endpoint(r *http.Request) Endpoint {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return Endpoint{}
|
return Endpoint{}
|
||||||
}
|
}
|
||||||
return m[key]
|
|
||||||
|
endpoint, ok := m[key]
|
||||||
|
if !ok {
|
||||||
|
return Endpoint{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, iffer := range endpoint.If {
|
||||||
|
matches := true
|
||||||
|
for k, v := range iffer.Headers {
|
||||||
|
matches = matches && r.Header.Get(k) == v
|
||||||
|
}
|
||||||
|
if matches {
|
||||||
|
return iffer.Then
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
type redirPurge struct {
|
type redirPurge struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user