Move responceCode out of HandleFunc.

This commit is contained in:
Christian Groschupp 2019-10-04 15:07:31 +02:00
parent dc36836800
commit a46ee952a6
No known key found for this signature in database
GPG Key ID: F164E00C6EDA908F
1 changed files with 6 additions and 5 deletions

View File

@ -209,12 +209,13 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
proxy := NewWebSocketOrRestReverseProxy(u, opts, auth) proxy := NewWebSocketOrRestReverseProxy(u, opts, auth)
serveMux.Handle(path, proxy) serveMux.Handle(path, proxy)
case "static": case "static":
serveMux.HandleFunc(path, func(rw http.ResponseWriter, req *http.Request) {
responseCode, err := strconv.Atoi(host) responseCode, err := strconv.Atoi(host)
if err != nil { if err != nil {
logger.Printf("unable to convert %q to int, use default \"200\"", host) logger.Printf("unable to convert %q to int, use default \"200\"", host)
responseCode = 200 responseCode = 200
} }
serveMux.HandleFunc(path, func(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(responseCode) rw.WriteHeader(responseCode)
fmt.Fprintf(rw, "Authenticated") fmt.Fprintf(rw, "Authenticated")
}) })