2022-04-20 09:17:20 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-05-30 14:01:20 +00:00
|
|
|
"github.com/valyala/fasthttp"
|
2022-04-20 09:17:20 +00:00
|
|
|
)
|
|
|
|
|
2023-05-30 14:01:20 +00:00
|
|
|
// 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)
|
|
|
|
}
|