http

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 5 Imported by: 17

Documentation

Overview

Package http contains utility methods related to HTTP.

Index

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

func EncodeHTTPHeaders(h http.Header) string

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

func WithRequestContext(ctx context.Context, val *fasthttp.RequestCtx) context.Context

WithRequestContext sets fasthttp header in context.

Types

type ContextKey

type ContextKey string

ContextKey defines context key of http.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL