Skip to content

Commit

Permalink
misc: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Deems authored and kevindweb committed Dec 30, 2024
1 parent 70305d7 commit 0f2f97c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions proxymw/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ func NewFromConfig(cfg Config, client ProxyClient) ProxyClient {

// ServeHTTP processes requests through the middleware chain
func (se *ServeEntry) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), se.timeout)
defer cancel()
ctx := r.Context()
if se.timeout > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(ctx, se.timeout)
defer cancel()
}

rr := &RequestResponseWrapper{
w: w,
Expand Down
4 changes: 2 additions & 2 deletions proxyutil/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func ParseConfigFlags() (Config, error) {
return Config{}, err
}

queries, err := parseBackpressureQueries(
queries, err := ParseBackpressureQueries(
bpQueries, bpQueryNames, bpWarnThresholds, bpEmergencyThresholds,
)
if err != nil {
Expand Down Expand Up @@ -282,7 +282,7 @@ func parsePaths(paths string) ([]string, error) {
return pathList, nil
}

func parseBackpressureQueries(
func ParseBackpressureQueries(
bpQueries, bpQueryNames []string, bpWarnThresholds, bpEmergencyThresholds []float64,
) ([]proxymw.BackpressureQuery, error) {
n := len(bpQueries)
Expand Down

0 comments on commit 0f2f97c

Please sign in to comment.