@@ -13,19 +13,19 @@ type GitLabGateway struct {
13
13
proxy * httputil.ReverseProxy
14
14
}
15
15
16
- var pathRegexp = regexp .MustCompile ("^/gitlab/?" )
17
- var allowedRegexp = regexp .MustCompile ("^/gitlab/repository/(files|commits|tree)/?" )
16
+ var gitlabPathRegexp = regexp .MustCompile ("^/gitlab/?" )
17
+ var gitlabAllowedRegexp = regexp .MustCompile ("^/gitlab/repository/(files|commits|tree)/?" )
18
18
19
19
func NewGitLabGateway () * GitLabGateway {
20
20
return & GitLabGateway {
21
21
proxy : & httputil.ReverseProxy {
22
- Director : director ,
22
+ Director : gitlabDirector ,
23
23
Transport : & GitLabTransport {},
24
24
},
25
25
}
26
26
}
27
27
28
- func director (r * http.Request ) {
28
+ func gitlabDirector (r * http.Request ) {
29
29
ctx := r .Context ()
30
30
target := getProxyTarget (ctx )
31
31
accessToken := getAccessToken (ctx )
@@ -34,7 +34,7 @@ func director(r *http.Request) {
34
34
r .Host = target .Host
35
35
r .URL .Scheme = target .Scheme
36
36
r .URL .Host = target .Host
37
- r .URL .Path = singleJoiningSlash (target .Path , pathRegexp .ReplaceAllString (r .URL .Path , "/" ))
37
+ r .URL .Path = singleJoiningSlash (target .Path , gitlabPathRegexp .ReplaceAllString (r .URL .Path , "/" ))
38
38
if targetQuery == "" || r .URL .RawQuery == "" {
39
39
r .URL .RawQuery = targetQuery + r .URL .RawQuery
40
40
} else {
@@ -65,7 +65,7 @@ func (gl *GitLabGateway) ServeHTTP(w http.ResponseWriter, r *http.Request) {
65
65
return
66
66
}
67
67
68
- endpoint := config .Gitlab .Endpoint
68
+ endpoint := config .GitLab .Endpoint
69
69
apiURL := singleJoiningSlash (endpoint , "/repos/" + config .GitLab .Repo )
70
70
target , err := url .Parse (apiURL )
71
71
if err != nil {
@@ -86,7 +86,7 @@ func (gl *GitLabGateway) authenticate(w http.ResponseWriter, r *http.Request) er
86
86
return errors .New ("Access to endpoint not allowed: no claims found in Bearer token" )
87
87
}
88
88
89
- if ! allowedRegexp .MatchString (r .URL .Path ) {
89
+ if ! gitlabAllowedRegexp .MatchString (r .URL .Path ) {
90
90
return errors .New ("Access to endpoint not allowed: this part of GitHub's API has been restricted" )
91
91
}
92
92
0 commit comments