Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authorVladimir Shushlin <v.shushlin@gmail.com>2021-12-06 16:24:20 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2021-12-07 12:07:31 +0300
commit0ab62643e5b61daf82ecf5a2c1ed196796059514 (patch)
tree87c3aad7e854a40b86ca1c0578d20135965cddd4 /app.go
parentd228c13c76d11091f8514e40940dc7df1b633e5a (diff)
refactor: enable unparam in .golangci.yml
and fix offences
Diffstat (limited to 'app.go')
-rw-r--r--app.go26
1 files changed, 10 insertions, 16 deletions
diff --git a/app.go b/app.go
index 18513f0d..5086e0e1 100644
--- a/app.go
+++ b/app.go
@@ -79,14 +79,6 @@ func (a *theApp) ServeTLS(ch *cryptotls.ClientHelloInfo) (*cryptotls.Certificate
return nil, nil
}
-func (a *theApp) healthCheck(w http.ResponseWriter, r *http.Request, https bool) {
- if a.isReady() {
- w.Write([]byte("success\n"))
- } else {
- http.Error(w, "not yet ready", http.StatusServiceUnavailable)
- }
-}
-
func (a *theApp) redirectToHTTPS(w http.ResponseWriter, r *http.Request, statusCode int) {
u := *r.URL
u.Scheme = request.SchemeHTTPS
@@ -103,15 +95,14 @@ func (a *theApp) domain(ctx context.Context, host string) (*domain.Domain, error
// checkAuthAndServeNotFound performs the auth process if domain can't be found
// the main purpose of this process is to avoid leaking the project existence/not-existence
// by behaving the same if user has no access to the project or if project simply does not exists
-func (a *theApp) checkAuthAndServeNotFound(domain *domain.Domain, w http.ResponseWriter, r *http.Request) bool {
+func (a *theApp) checkAuthAndServeNotFound(domain *domain.Domain, w http.ResponseWriter, r *http.Request) {
// To avoid user knowing if pages exist, we will force user to login and authorize pages
if a.Auth.CheckAuthenticationWithoutProject(w, r, domain) {
- return true
+ return
}
// auth succeeded try to serve the correct 404 page
domain.ServeNotFoundAuthFailed(w, r)
- return true
}
func (a *theApp) tryAuxiliaryHandlers(w http.ResponseWriter, r *http.Request, https bool, host string, domain *domain.Domain) bool {
@@ -138,9 +129,8 @@ func (a *theApp) tryAuxiliaryHandlers(w http.ResponseWriter, r *http.Request, ht
}
// redirect to auth and serve not found
- if a.checkAuthAndServeNotFound(domain, w, r) {
- return true
- }
+ a.checkAuthAndServeNotFound(domain, w, r)
+ return true
}
if !https && domain.IsHTTPSOnly(r) {
@@ -153,8 +143,12 @@ func (a *theApp) tryAuxiliaryHandlers(w http.ResponseWriter, r *http.Request, ht
// healthCheckMiddleware is serving the application status check
func (a *theApp) healthCheckMiddleware(handler http.Handler) (http.Handler, error) {
- healthCheck := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- a.healthCheck(w, r, request.IsHTTPS(r))
+ healthCheck := http.HandlerFunc(func(w http.ResponseWriter, _r *http.Request) {
+ if a.isReady() {
+ w.Write([]byte("success\n"))
+ } else {
+ http.Error(w, "not yet ready", http.StatusServiceUnavailable)
+ }
})
loggedHealthCheck, err := logging.BasicAccessLogger(healthCheck, a.config.Log.Format, nil)