Documentation ¶
Overview ¶
Package http contains utility methods related to HTTP.
Index ¶
- Constants
- func EncodeHTTPHeaders(h http.Header) string
- func GetClientIP(fctx *fasthttp.RequestCtx) string
- func GetParam(ctx *fasthttp.RequestCtx, key string) (string, bool)
- func GetString(fctx *fasthttp.RequestCtx, key string) (ret string)
- func RequestContext(ctx context.Context) *fasthttp.RequestCtx
- func WithRequestContext(ctx context.Context, val *fasthttp.RequestCtx) context.Context
- type ContextKey
Constants ¶
View Source
const ( // TRPCGatewayHTTPHeader http header TRPCGatewayHTTPHeader = "TRPC_GATEWAY_HTTP_HEADER" // TRPCGatewayHTTPQuery http raw uri TRPCGatewayHTTPQuery = "TRPC_GATEWAY_HTTP_QUERY" )
View Source
const ( // XUpstreamLatencyHeader is the upstream latency response header. XUpstreamLatencyHeader = "X-Upstream-Latency" // XProxyLatencyHeader is the gateway latency response header. XProxyLatencyHeader = "X-Proxy-Latency" // XRouterIDHeader is the router ID. XRouterIDHeader = "X-Router-Id" // GatewayName is the name of the gateway service. GatewayName = "tRPC-Gateway" )
View Source
const ContextKeyReq = ContextKey("TRPC_SERVER_FASTHTTP_REQ")
ContextKeyReq key of fasthttp header
Variables ¶
This section is empty.
Functions ¶
func EncodeHTTPHeaders ¶
EncodeHTTPHeaders encode http headers to string
func GetClientIP ¶
func GetClientIP(fctx *fasthttp.RequestCtx) string
GetClientIP returns the client's IP address.
func GetParam ¶
func GetParam(ctx *fasthttp.RequestCtx, key string) (string, bool)
GetParam retrieves the parameter and checks if it exists or not.
func GetString ¶
func GetString(fctx *fasthttp.RequestCtx, key string) (ret string)
GetString returns HTTP request parameters.
func RequestContext ¶
func RequestContext(ctx context.Context) *fasthttp.RequestCtx
RequestContext gets the corresponding fasthttp header from context.
func WithRequestContext ¶
WithRequestContext sets fasthttp header in context.
Types ¶
Click to show internal directories.
Click to hide internal directories.