mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-21 10:17:22 +02:00
Make the Upstreams mux configurable
This commit changes Upstreams from []Upstream to a struct{}
moving the previous []Upstream into .Configs and adjusts all uses of it.
This commit is contained in:
@@ -27,7 +27,7 @@ func NewProxy(upstreams options.Upstreams, sigData *options.SignatureData, write
|
||||
serveMux: mux.NewRouter(),
|
||||
}
|
||||
|
||||
for _, upstream := range sortByPathLongest(upstreams) {
|
||||
for _, upstream := range sortByPathLongest(upstreams.Configs) {
|
||||
if upstream.Static {
|
||||
if err := m.registerStaticResponseHandler(upstream, writer); err != nil {
|
||||
return nil, fmt.Errorf("could not register static upstream %q: %v", upstream.ID, err)
|
||||
@@ -153,7 +153,7 @@ func registerTrailingSlashHandler(serveMux *mux.Router) {
|
||||
// precedence (note this is the input to the rewrite logic).
|
||||
// This does not account for when a rewrite would actually make the path shorter.
|
||||
// This should maintain the sorting behaviour of the standard go serve mux.
|
||||
func sortByPathLongest(in options.Upstreams) options.Upstreams {
|
||||
func sortByPathLongest(in []options.Upstream) []options.Upstream {
|
||||
sort.Slice(in, func(i, j int) bool {
|
||||
iRW := in[i].RewriteTarget
|
||||
jRW := in[j].RewriteTarget
|
||||
|
||||
Reference in New Issue
Block a user