forked from TrueCloudLab/frostfs-http-gw
[#54] Fix linter warnings
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
01b9df83e6
commit
f17f6747c4
4 changed files with 31 additions and 33 deletions
|
@ -13,9 +13,11 @@ import (
|
|||
|
||||
type fromHandler = func(h *fasthttp.RequestHeader) []byte
|
||||
|
||||
type ctxKey string
|
||||
|
||||
const (
|
||||
bearerTokenHdr = "Bearer"
|
||||
bearerTokenKey = "__context_bearer_token_key"
|
||||
bearerTokenHdr = "Bearer"
|
||||
bearerTokenKey ctxKey = "__context_bearer_token_key"
|
||||
)
|
||||
|
||||
// BearerToken usage:
|
||||
|
@ -50,12 +52,12 @@ func BearerTokenFromCookie(h *fasthttp.RequestHeader) []byte {
|
|||
|
||||
// StoreBearerTokenAppCtx extracts a bearer token from the header or cookie and stores
|
||||
// it in the application context.
|
||||
func StoreBearerTokenAppCtx(ctx *fasthttp.RequestCtx, appCtx context.Context) (context.Context, error) {
|
||||
tkn, err := fetchBearerToken(ctx)
|
||||
func StoreBearerTokenAppCtx(ctx context.Context, req *fasthttp.RequestCtx) (context.Context, error) {
|
||||
tkn, err := fetchBearerToken(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newCtx := context.WithValue(appCtx, bearerTokenKey, tkn)
|
||||
newCtx := context.WithValue(ctx, bearerTokenKey, tkn)
|
||||
return newCtx, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue