mirror of https://github.com/harness/drone.git
[MISC] Fix routing for gitXXX and apiXXX space names (#2035)
parent
44d1a82e6f
commit
ea49937a1e
|
@ -128,18 +128,16 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
// stripPrefix removes the prefix from the request path (or noop if it's not there).
|
// stripPrefix removes the prefix from the request path (or noop if it's not there).
|
||||||
func stripPrefix(prefix string, req *http.Request) error {
|
func stripPrefix(prefix string, req *http.Request) error {
|
||||||
p := req.URL.Path
|
if !strings.HasPrefix(req.URL.Path, prefix) {
|
||||||
if !strings.HasPrefix(p, prefix) {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return request.ReplacePrefix(req, req.URL.Path[:len(prefix)], "")
|
return request.ReplacePrefix(req, prefix, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// isGitTraffic returns true iff the request is identified as part of the git http protocol.
|
// isGitTraffic returns true iff the request is identified as part of the git http protocol.
|
||||||
func (r *Router) isGitTraffic(req *http.Request) bool {
|
func (r *Router) isGitTraffic(req *http.Request) bool {
|
||||||
// git traffic is always reachable via the git mounting path.
|
// git traffic is always reachable via the git mounting path.
|
||||||
p := req.URL.Path
|
if strings.HasPrefix(req.URL.Path, GitMount+"/") {
|
||||||
if strings.HasPrefix(p, GitMount) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +158,5 @@ func (r *Router) isGitTraffic(req *http.Request) bool {
|
||||||
|
|
||||||
// isAPITraffic returns true iff the request is identified as part of our rest API.
|
// isAPITraffic returns true iff the request is identified as part of our rest API.
|
||||||
func (r *Router) isAPITraffic(req *http.Request) bool {
|
func (r *Router) isAPITraffic(req *http.Request) bool {
|
||||||
p := req.URL.Path
|
return strings.HasPrefix(req.URL.Path, APIMount+"/")
|
||||||
return strings.HasPrefix(p, APIMount)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue