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:
authorJaime Martinez <jmartinez@gitlab.com>2021-07-07 10:03:54 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-07-07 10:03:54 +0300
commitc81339af0bd218ccb956f53d0f7bbabef835a5a4 (patch)
tree8ea2b81a4987cd442943657ff969473496bacb09 /app.go
parent86afc1dfeeb07fbc140d08ef8cdcfd8cbd4d7bcb (diff)
Add correlation_id to outbound requests
Diffstat (limited to 'app.go')
-rw-r--r--app.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/app.go b/app.go
index 8f17e535..c9d50223 100644
--- a/app.go
+++ b/app.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
cryptotls "crypto/tls"
"errors"
"fmt"
@@ -66,7 +67,7 @@ func (a *theApp) ServeTLS(ch *cryptotls.ClientHelloInfo) (*cryptotls.Certificate
return nil, nil
}
- if domain, _ := a.domain(ch.ServerName); domain != nil {
+ if domain, _ := a.domain(context.Background(), ch.ServerName); domain != nil {
tls, _ := domain.EnsureCertificate()
return tls, nil
}
@@ -93,13 +94,13 @@ func (a *theApp) redirectToHTTPS(w http.ResponseWriter, r *http.Request, statusC
func (a *theApp) getHostAndDomain(r *http.Request) (string, *domain.Domain, error) {
host := request.GetHostWithoutPort(r)
- domain, err := a.domain(host)
+ domain, err := a.domain(r.Context(), host)
return host, domain, err
}
-func (a *theApp) domain(host string) (*domain.Domain, error) {
- return a.domains.GetDomain(host)
+func (a *theApp) domain(ctx context.Context, host string) (*domain.Domain, error) {
+ return a.domains.GetDomain(ctx, host)
}
// checkAuthAndServeNotFound performs the auth process if domain can't be found
@@ -346,12 +347,6 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
// Custom response headers
handler = a.customHeadersMiddleware(handler)
- //handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- // fmt.Printf("the req headers: %+v\n", r.Header)
- // fmt.Printf("the correlationID must have been here: %q\n", correlation.ExtractFromContext(r.Context()))
- // handler.ServeHTTP(w, r)
- // return
- //})
// Correlation ID injection middleware
var correlationOpts []correlation.InboundHandlerOption