frostfs-http-gw/utils/util.go

18 lines
435 B
Go
Raw Normal View History

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)
}