MCPcopy Create free account
hub / github.com/asim/git-http-backend / Handler

Function Handler

server/server.go:79–112  ·  view source on GitHub ↗

Request handling function

()

Source from the content-addressed store, hash-verified

77// Request handling function
78
79func 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

Callers 1

mainFunction · 0.92

Calls 3

renderMethodNotAllowedFunction · 0.85
getGitDirFunction · 0.85
renderNotFoundFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…