mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
feat(rules.on): support route directive
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp/httpheaders"
|
||||
"github.com/yusing/go-proxy/internal/net/types"
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
)
|
||||
@@ -31,6 +32,7 @@ const (
|
||||
OnPath = "path"
|
||||
OnRemote = "remote"
|
||||
OnBasicAuth = "basic_auth"
|
||||
OnRoute = "route"
|
||||
)
|
||||
|
||||
var checkers = map[string]struct {
|
||||
@@ -229,6 +231,21 @@ var checkers = map[string]struct {
|
||||
}
|
||||
},
|
||||
},
|
||||
OnRoute: {
|
||||
help: Help{
|
||||
command: OnRoute,
|
||||
args: map[string]string{
|
||||
"route": "the route name",
|
||||
},
|
||||
},
|
||||
validate: validateSingleArg,
|
||||
builder: func(args any) CheckFunc {
|
||||
route := args.(string)
|
||||
return func(_ Cache, r *http.Request) bool {
|
||||
return r.Header.Get(httpheaders.HeaderUpstreamName) == route
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
|
||||
|
||||
Reference in New Issue
Block a user