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