-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
35 lines (27 loc) · 1.04 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package requestutil
import (
"github.com/valyala/fasthttp"
)
const (
USER_STORE_KEY_RESPONSE_STATE = "github.com/Bofry/host-fasthttp/internal/response::ResponseState"
USER_STORE_KEY_SEVERITY_TRACER = "github.com/Bofry/trace::SeverityTracer"
USER_STORE_KEY_SEVERITY_SPAN = "github.com/Bofry/trace::SeveritySpan"
)
func InjectResponseState(ctx *fasthttp.RequestCtx, responseState interface{}) {
ctx.SetUserValue(USER_STORE_KEY_RESPONSE_STATE, responseState)
}
func ExtractResponseState(ctx *fasthttp.RequestCtx) interface{} {
return ctx.UserValue(USER_STORE_KEY_RESPONSE_STATE)
}
func InjectTracer(ctx *fasthttp.RequestCtx, tracer interface{}) {
ctx.SetUserValue(USER_STORE_KEY_SEVERITY_TRACER, tracer)
}
func ExtractTracer(ctx *fasthttp.RequestCtx) interface{} {
return ctx.UserValue(USER_STORE_KEY_SEVERITY_TRACER)
}
func InjectSpan(ctx *fasthttp.RequestCtx, span interface{}) {
ctx.SetUserValue(USER_STORE_KEY_SEVERITY_SPAN, span)
}
func ExtractSpan(ctx *fasthttp.RequestCtx) interface{} {
return ctx.UserValue(USER_STORE_KEY_SEVERITY_SPAN)
}