FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: FromApp inherits the app-level api {} config into site handlers by jtelo88 · Pull Request #142 · caddyserver/cache-handler · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 11 additions & 0 deletions httpcache.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
}
}

// The Caddyfile `api {}` block is global-only (parseCaddyfileGlobalOption
// rejects it inside site blocks), so a handler's own configuration can
// only carry an API config via raw JSON. When it doesn't, inherit the
// app-level API like every other app-level default merged below —
// otherwise GenerateHandlerMap sees a zero API config in every handler
// instance and the souin API is unreachable in-band on any listener
// (requests fall through the cache handler as if the API didn't exist).
if !s.Configuration.API.Souin.Enable && !s.Configuration.API.Debug.Enable && !s.Configuration.API.Prometheus.Enable {
s.Configuration.API = app.API
}

if app.GetTTL() == 0 {
if s.Configuration.DefaultCache.GetTTL() == 0 {
app.TTL = configurationtypes.Duration{Duration: 120 * time.Second}
Expand Down

Back | FazBrowse Home | New Git URL