Request handling function
()
| 77 | // Request handling function |
| 78 | |
| 79 | func Handler() http.HandlerFunc { |
| 80 | return func(w http.ResponseWriter, r *http.Request) { |
| 81 | log.Printf("%s %s %s %s", r.RemoteAddr, r.Method, r.URL.Path, r.Proto) |
| 82 | for match, service := range services { |
| 83 | re, err := regexp.Compile(match) |
| 84 | if err != nil { |
| 85 | log.Print(err) |
| 86 | } |
| 87 | |
| 88 | if m := re.FindStringSubmatch(r.URL.Path); m != nil { |
| 89 | if service.Method != r.Method { |
| 90 | renderMethodNotAllowed(w, r) |
| 91 | return |
| 92 | } |
| 93 | |
| 94 | rpc := service.Rpc |
| 95 | file := strings.Replace(r.URL.Path, m[1]+"/", "", 1) |
| 96 | dir, err := getGitDir(m[1]) |
| 97 | |
| 98 | if err != nil { |
| 99 | log.Print(err) |
| 100 | renderNotFound(w) |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | hr := HandlerReq{w, r, rpc, dir, file} |
| 105 | service.Handler(hr) |
| 106 | return |
| 107 | } |
| 108 | } |
| 109 | renderNotFound(w) |
| 110 | return |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | // Actual command handling functions |
| 115 |
no test coverage detected
searching dependent graphs…