Commit b0525d6c authored by Jacob Vosmaer's avatar Jacob Vosmaer

Compile routes later during boot

parent bd5ec001
......@@ -57,7 +57,10 @@ const ciAPIPattern = `^/ci/api/`
// Routing table
// We match against URI not containing the relativeUrlRoot:
// see upstream.ServeHTTP
var httpRoutes = [...]httpRoute{
var httpRoutes []httpRoute
func compileRoutes() {
httpRoutes = []httpRoute{
// Git Clone
httpRoute{"GET", regexp.MustCompile(gitProjectPattern + `info/refs\z`), repoPreAuthorizeHandler(handleGetInfoRefs)},
httpRoute{"POST", regexp.MustCompile(gitProjectPattern + `git-upload-pack\z`), repoPreAuthorizeHandler(contentEncodingHandler(handlePostRPC))},
......@@ -108,6 +111,7 @@ var httpRoutes = [...]httpRoute{
),
),
},
}
}
func main() {
......@@ -169,5 +173,6 @@ func main() {
}
upstream := newUpstream(*authBackend, proxyTransport)
compileRoutes()
log.Fatal(http.Serve(listener, upstream))
}
......@@ -326,6 +326,7 @@ func testAuthServer(url *regexp.Regexp, code int, body interface{}) *httptest.Se
}
func startWorkhorseServer(authBackend string) *httptest.Server {
compileRoutes()
return httptest.NewServer(newUpstream(authBackend, nil))
}
......
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