diff --git a/README.md b/README.md index 91ce11a..2b79cac 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ http: showDetails: true theme: hacker-terminal refreshFrequency: 5s + readyOnStart: false ``` | Option | Type | Required | Default | Description | @@ -93,6 +94,7 @@ http: | `dynamic.showDetails` | boolean | No | Server default | Show detailed information on the waiting page | | `dynamic.theme` | string | No | Server default | Theme for the waiting page (e.g., `hacker-terminal`, `ghost`, `matrix`) | | `dynamic.refreshFrequency` | duration | No | Server default | How often the waiting page checks if instances are ready | +| `dynamic.readyOnStart` | boolean | No | `false` | Force `X-Sablier-Session-Status: ready` immediately regardless of instance health. No waiting page is shown. | | `blocking.timeout` | duration | No | - | Maximum time to wait for instances to become ready | | `ignoreUserAgent` | string or string\[\] | No | - | List of [Go regexp](https://pkg.go.dev/regexp/syntax) patterns. Requests whose `User-Agent` matches any pattern receive an immediate `HTTP 200` without waking the container. Can be specified as a YAML list (preferred) or as a single string (backward-compatible). Patterns are case-sensitive unless the `(?i)` flag is used. | diff --git a/config.go b/config.go index 0f19af6..9f7ae19 100644 --- a/config.go +++ b/config.go @@ -44,6 +44,7 @@ type DynamicConfiguration struct { ShowDetails *bool `yaml:"showDetails"` Theme string `yaml:"theme"` RefreshFrequency string `yaml:"refreshFrequency"` + ReadyOnStart *bool `yaml:"readyOnStart"` } type BlockingConfiguration struct { @@ -165,6 +166,10 @@ func (c *Config) buildDynamicRequest(middlewareName string) (*http.Request, erro q.Add("show_details", strconv.FormatBool(*c.Dynamic.ShowDetails)) } + if c.Dynamic.ReadyOnStart != nil { + q.Add("ready_on_start", strconv.FormatBool(*c.Dynamic.ReadyOnStart)) + } + request.URL.RawQuery = q.Encode() return request, nil diff --git a/config_test.go b/config_test.go index 3c11d95..1ace7a1 100644 --- a/config_test.go +++ b/config_test.go @@ -152,6 +152,18 @@ func TestConfig_BuildRequest(t *testing.T) { want: createRequest("GET", "http://sablier:10000/api/strategies/dynamic?display_name=sablier-middleware&names=nginx&names=apache&refresh_frequency=1m&session_duration=1m&show_details=false", nil), wantErr: false, }, + { + name: "dynamic session with readyOnStart", + fields: fields{ + SablierURL: "http://sablier:10000", + Names: "nginx", + Dynamic: &traefik.DynamicConfiguration{ + ReadyOnStart: &tru, + }, + }, + want: createRequest("GET", "http://sablier:10000/api/strategies/dynamic?display_name=sablier-middleware&names=nginx&ready_on_start=true", nil), + wantErr: false, + }, { name: "dynamic session without show details set", fields: fields{