Commit 34fa7497 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use http.Handler in httpRoute

parent 570911ae
...@@ -41,9 +41,9 @@ var responseHeadersTimeout = flag.Duration("proxyHeadersTimeout", time.Minute, " ...@@ -41,9 +41,9 @@ var responseHeadersTimeout = flag.Duration("proxyHeadersTimeout", time.Minute, "
var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app") var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app")
type httpRoute struct { type httpRoute struct {
method string method string
regex *regexp.Regexp regex *regexp.Regexp
handleFunc httpHandleFunc handler http.Handler
} }
type httpHandleFunc func(http.ResponseWriter, *http.Request) type httpHandleFunc func(http.ResponseWriter, *http.Request)
...@@ -93,8 +93,8 @@ func compileRoutes(u *upstream) { ...@@ -93,8 +93,8 @@ func compileRoutes(u *upstream) {
httpRoute{"POST", regexp.MustCompile(ciAPIPattern + `v1/builds/[0-9]+/artifacts\z`), contentEncodingHandler(api.artifactsAuthorizeHandler(handleFileUploads(proxy)))}, httpRoute{"POST", regexp.MustCompile(ciAPIPattern + `v1/builds/[0-9]+/artifacts\z`), contentEncodingHandler(api.artifactsAuthorizeHandler(handleFileUploads(proxy)))},
// Explicitly proxy API requests // Explicitly proxy API requests
httpRoute{"", regexp.MustCompile(apiPattern), proxy.ServeHTTP}, httpRoute{"", regexp.MustCompile(apiPattern), proxy},
httpRoute{"", regexp.MustCompile(ciAPIPattern), proxy.ServeHTTP}, httpRoute{"", regexp.MustCompile(ciAPIPattern), proxy},
// Serve assets // Serve assets
httpRoute{"", regexp.MustCompile(`^/assets/`), httpRoute{"", regexp.MustCompile(`^/assets/`),
......
...@@ -139,5 +139,5 @@ func (u *upstream) ServeHTTP(ow http.ResponseWriter, r *http.Request) { ...@@ -139,5 +139,5 @@ func (u *upstream) ServeHTTP(ow http.ResponseWriter, r *http.Request) {
return return
} }
g.handleFunc(&w, r) g.handler.ServeHTTP(&w, r)
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment