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

request.go « request « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dad6af3dcbe803390cfa6a435abb14a30584b347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package request

import (
	"context"
	"net/http"
)

type ctxKey string

const (
	ctxHTTPSKey ctxKey = "https"
)

// WithHTTPSFlag saves https flag in request's context
func WithHTTPSFlag(r *http.Request, https bool) *http.Request {
	ctx := context.WithValue(r.Context(), ctxHTTPSKey, https)

	return r.WithContext(ctx)
}

// IsHTTPS restores https flag from request's context
func IsHTTPS(r *http.Request) bool {
	return r.Context().Value(ctxHTTPSKey).(bool)
}