headers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudFlareIncomingHeaderPrefix = "Cf-"
	CloudFlareInternalHeaderPrefix = "Cf-Original-"
)
View Source
const (
	Accept                        = "Accept"
	AcceptLanguage                = "Accept-Language"
	AccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	AccessControlAllowMethods     = "Access-Control-Allow-Methods"
	AccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	AccessControlRequestMethod    = "Access-Control-Request-Method"
	AccessControlRequestHeaders   = "Access-Control-Request-Headers"
	AccessControlMaxAge           = "Access-Control-Max-Age"
	Authorization                 = "Authorization"
	CfConnectingIP                = "Cf-Connecting-IP"
	ContentType                   = "Content-Type"
	Origin                        = "Origin"
	Referer                       = "Referer"
	RetryAfter                    = "Retry-After"
	UserAgent                     = "User-Agent"
	Vary                          = "Vary"
	XCtCaptchaChallenge           = "X-Ct-Captcha-Challenge"
	XForwardedFor                 = "X-Forwarded-For"
	XRateLimit                    = "X-Ratelimit-Limit"
	XRateLimitRemaining           = "X-Ratelimit-Remaining"
	XRealIp                       = "X-Real-IP"
)

Variables

View Source
var (
	CorsAllowedMethods = []string{
		fasthttp.MethodGet,
		fasthttp.MethodPost,
		fasthttp.MethodPut,
		fasthttp.MethodPatch,
		fasthttp.MethodDelete,
		fasthttp.MethodOptions,
	}
	CorsAllowedHeaders = []string{
		ContentType,
		XCtCaptchaChallenge,
		"*",
	}
	CorsIgnorePaths = map[string]bool{
		"/live":  true,
		"/ready": true,
	}
)
View Source
var (
	ContentTypeJson = []byte("application/json")
	ContentTypeForm = []byte("application/x-www-form-urlencoded")
)

Functions

func CopyCloudFlareHeaders

func CopyCloudFlareHeaders(ctx *fasthttp.RequestCtx, req *fasthttp.Request)

CopyCloudFlareHeaders keep original CloudFlare incoming headers for other services behind gateway

func CopyFromRequest

func CopyFromRequest(ctx *fasthttp.RequestCtx, req *fasthttp.Request, headers []string)

func CopyFromResponse

func CopyFromResponse(resp *fasthttp.Response, ctx *fasthttp.RequestCtx, headers []string)

func CorsHandler

CorsHandler is a middleware to write default CORS headers if no forwarded

func GetClientIPFromContext

func GetClientIPFromContext(ctx *fasthttp.RequestCtx) string

func Handler

Handler is a middleware to write default headers for each response

func WriteBearerToken

func WriteBearerToken(req *fasthttp.Request, token string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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