Denis Kirillov
3741e3b003
All checks were successful
/ DCO (pull_request) Successful in 1m22s
/ Builds (1.21) (pull_request) Successful in 1m58s
/ Builds (1.22) (pull_request) Successful in 1m53s
/ Vulncheck (pull_request) Successful in 3m32s
/ Lint (pull_request) Successful in 5m1s
/ Tests (1.21) (pull_request) Successful in 2m38s
/ Tests (1.22) (pull_request) Successful in 3m4s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
17 lines
435 B
Go
17 lines
435 B
Go
package utils
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/valyala/fasthttp"
|
|
)
|
|
|
|
// SetContextToRequest adds new context to fasthttp request.
|
|
func SetContextToRequest(ctx context.Context, c *fasthttp.RequestCtx) {
|
|
c.SetUserValue("context", ctx)
|
|
}
|
|
|
|
// GetContextFromRequest returns main context from fasthttp request context.
|
|
func GetContextFromRequest(c *fasthttp.RequestCtx) context.Context {
|
|
return c.UserValue("context").(context.Context)
|
|
}
|