forked from TrueCloudLab/frostfs-http-gw
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)
|
|
}
|