Skip to content

Commit 66bcd32

Browse files
committed
Fix redeclaration errors in gitlab handler
1 parent 51e2bb1 commit 66bcd32

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

api/gitlab.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ type GitLabGateway struct {
1313
proxy *httputil.ReverseProxy
1414
}
1515

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)/?")
1818

1919
func NewGitLabGateway() *GitLabGateway {
2020
return &GitLabGateway{
2121
proxy: &httputil.ReverseProxy{
22-
Director: director,
22+
Director: gitlabDirector,
2323
Transport: &GitLabTransport{},
2424
},
2525
}
2626
}
2727

28-
func director(r *http.Request) {
28+
func gitlabDirector(r *http.Request) {
2929
ctx := r.Context()
3030
target := getProxyTarget(ctx)
3131
accessToken := getAccessToken(ctx)
@@ -34,7 +34,7 @@ func director(r *http.Request) {
3434
r.Host = target.Host
3535
r.URL.Scheme = target.Scheme
3636
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, "/"))
3838
if targetQuery == "" || r.URL.RawQuery == "" {
3939
r.URL.RawQuery = targetQuery + r.URL.RawQuery
4040
} else {
@@ -65,7 +65,7 @@ func (gl *GitLabGateway) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6565
return
6666
}
6767

68-
endpoint := config.Gitlab.Endpoint
68+
endpoint := config.GitLab.Endpoint
6969
apiURL := singleJoiningSlash(endpoint, "/repos/"+config.GitLab.Repo)
7070
target, err := url.Parse(apiURL)
7171
if err != nil {
@@ -86,7 +86,7 @@ func (gl *GitLabGateway) authenticate(w http.ResponseWriter, r *http.Request) er
8686
return errors.New("Access to endpoint not allowed: no claims found in Bearer token")
8787
}
8888

89-
if !allowedRegexp.MatchString(r.URL.Path) {
89+
if !gitlabAllowedRegexp.MatchString(r.URL.Path) {
9090
return errors.New("Access to endpoint not allowed: this part of GitHub's API has been restricted")
9191
}
9292

0 commit comments

Comments
 (0)