Skip to content

Commit

Permalink
@francislavoie review (first round)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Apr 23, 2024
1 parent 6c32b8e commit 8e39b5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions caddyconfig/httpcaddyfile/shorthands.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewShorthandReplacer() ShorthandReplacer {
{regexp.MustCompile(`{re\.([\w-\.]*)}`), "{http.regexp.$1}"},
{regexp.MustCompile(`{vars\.([\w-]*)}`), "{http.vars.$1}"},
{regexp.MustCompile(`{rp\.([\w-\.]*)}`), "{http.reverse_proxy.$1}"},
{regexp.MustCompile(`{ir\.([\w-\.]*)}`), "{http.intercept.$1}"},
{regexp.MustCompile(`{err\.([\w-\.]*)}`), "{http.error.$1}"},
{regexp.MustCompile(`{file_match\.([\w-]*)}`), "{http.matchers.file.$1}"},
}
Expand Down
2 changes: 1 addition & 1 deletion modules/caddyhttp/intercept/intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (irh *Intercept) Provision(ctx caddy.Context) error {
return nil
}

// TODO: use a single bufPool
var bufPool = sync.Pool{
New: func() any {
return new(bytes.Buffer)
Expand Down Expand Up @@ -113,6 +112,7 @@ func (irh interceptedResponseHandler) WriteHeader(statusCode int) {
func (ir Intercept) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
buf := bufPool.Get().(*bytes.Buffer)
buf.Reset()
defer bufPool.Put(buf)

repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
rec := interceptedResponseHandler{replacer: repl}
Expand Down

0 comments on commit 8e39b5a

Please sign in to comment.