frostfs-http-gw/utils/util.go
Denis Kirillov 3741e3b003 [#117] Add mocked handler for tests
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2024-06-18 12:04:14 +03:00

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