Skip to content

Commit

Permalink
fixup! Move ProxyFinder.checkForUpdates into request path
Browse files Browse the repository at this point in the history
Move check of `pf.fetcher == nil` outside the handler.

Addresses: samuong#16 (comment)
  • Loading branch information
camh- committed Aug 27, 2019
1 parent 9ddd9a5 commit 82a1dd2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions proxyfinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ func NewProxyFinder(pacurl string, wrapper *PACWrapper) *ProxyFinder {
}

func (pf *ProxyFinder) WrapHandler(next http.Handler) http.Handler {
// If we don't have a fetcher, don't wrap the handler as there's nothing to do.
if pf.fetcher == nil {
return next
}
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
if pf.fetcher != nil {
pf.checkForUpdates()
}
pf.checkForUpdates()
next.ServeHTTP(w, req)
})
}
Expand Down

0 comments on commit 82a1dd2

Please sign in to comment.