58c5d44f44
This change integrates the session management database functionality with the web application. Claim-based authentication has been removed in favor of session token-based authentication. Change-Id: I62a4f5354a3ed8ca80272814aad2448f901eab1b
26 lines
571 B
Go
26 lines
571 B
Go
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package console
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// requestKey is context key for Requests.
|
|
const requestKey key = 1
|
|
|
|
// WithRequest creates new context with *http.Request.
|
|
func WithRequest(ctx context.Context, req *http.Request) context.Context {
|
|
return context.WithValue(ctx, requestKey, req)
|
|
}
|
|
|
|
// GetRequest gets *http.Request from context.
|
|
func GetRequest(ctx context.Context) *http.Request {
|
|
if req, ok := ctx.Value(requestKey).(*http.Request); ok {
|
|
return req
|
|
}
|
|
return nil
|
|
}
|