Commit d40a5a8f authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use an early return in git_handler (less nesting)

parent 0c7758a2
......@@ -68,12 +68,25 @@ func main() {
func git_handler(w http.ResponseWriter, r *http.Request) {
var gl_id string
var path_match []string
var g gitService
var found_service bool
log.Print(r.Method, " ", r.URL)
for _, g := range git_services {
path_match := g.regexp.FindStringSubmatch(r.URL.Path)
// Look for a matching Git service
for _, g = range git_services {
path_match = g.regexp.FindStringSubmatch(r.URL.Path)
if r.Method == g.method && path_match != nil {
found_service = true
break
}
}
if !found_service {
http.Error(w, "Not Found", 404)
return
}
// Ask the auth backend if the request is allowed, and what the
// user ID (GL_ID) is.
auth_response, err := do_auth_request(r)
......@@ -111,11 +124,6 @@ func git_handler(w http.ResponseWriter, r *http.Request) {
}
g.handle_func(gl_id, g.rpc, path.Join(repo_root, found_path), w, r)
return
}
}
http.Error(w, "Not Found", 404)
return
}
func valid_path(p string) bool {
......
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