feat(layer,queue): implement matchURLs option
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good

This commit is contained in:
2023-07-05 13:54:01 -06:00
parent 1ffec1f173
commit ce2c19f9b3
5 changed files with 27 additions and 3 deletions

View File

@ -11,15 +11,15 @@ import (
type LayerOptions struct {
Capacity int64 `mapstructure:"capacity"`
Matchers []string `mapstructure:"matchers"`
KeepAlive time.Duration `mapstructure:"keepAlive"`
MatchURLs []string `mapstructure:"matchURLs"`
}
func fromStoreOptions(storeOptions store.LayerOptions, defaultKeepAlive time.Duration) (*LayerOptions, error) {
layerOptions := LayerOptions{
Capacity: 1000,
Matchers: []string{"*"},
KeepAlive: defaultKeepAlive,
MatchURLs: []string{"*"},
}
config := mapstructure.DecoderConfig{

View File

@ -1,6 +1,8 @@
package queue
import "time"
import (
"time"
)
type Options struct {
TemplateDir string

View File

@ -13,6 +13,7 @@ import (
"time"
"forge.cadoles.com/Cadoles/go-proxy"
"forge.cadoles.com/Cadoles/go-proxy/wildcard"
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director"
"forge.cadoles.com/cadoles/bouncer/internal/store"
"github.com/Masterminds/sprig/v3"
@ -57,6 +58,13 @@ func (q *Queue) Middleware(layer *store.Layer) proxy.Middleware {
return
}
matches := wildcard.MatchAny(r.URL.String(), options.MatchURLs...)
if !matches {
h.ServeHTTP(w, r)
return
}
defer q.updateMetrics(ctx, layer.Proxy, layer.Name, options)
cookieName := q.getCookieName(layer.Name)

View File

@ -9,6 +9,12 @@
},
"keepAlive": {
"type": "string"
},
"matchURLs": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false