fasthttputil

package
v0.0.0-...-cd0d1ff Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	XForwardedFor  = http.CanonicalHeaderKey("X-Forwarded-For")
	XForwardedHost = http.CanonicalHeaderKey("X-Forwarded-Host")
	XRealIP        = http.CanonicalHeaderKey("X-Real-IP")
)

Functions

func GetArgs

func GetArgs(ctx *fasthttp.RequestCtx, key string) []byte

GetArgs Post->Get->Header->Cookie

func GetResponseAge

func GetResponseAge(ctx *fasthttp.RequestCtx, def time.Duration) (age time.Duration, cache bool)

func IsFresh

func IsFresh(ctx *fasthttp.RequestCtx) bool

IsFresh check whether cache can be used in this fasthttp RequestCtx

func JSON

func JSON(ctx *fasthttp.RequestCtx, v interface{}) error

func Ok

func Ok(ctx *fasthttp.RequestCtx)

func ResponseDate

func ResponseDate(ctx *fasthttp.RequestCtx) (date time.Time, err error)

Date parses and returns the value of the Date header.

func StripPrefix

func StripPrefix(prefix string, h fasthttp.RequestHandler) fasthttp.RequestHandler

StripPrefix returns a handler that serves HTTP requests by removing the given prefix from the request URL's Path and invoking the handler h. StripPrefix handles a request for a path that doesn't begin with prefix by replying with an HTTP 404 not found error.

Types

type CacheControl

type CacheControl map[string]string

func ParseCacheControl

func ParseCacheControl(headers string) CacheControl

type HostSwitch

type HostSwitch map[string]fasthttp.RequestHandler

HostSwitch is the host-handler map

func (HostSwitch) Add

func (p HostSwitch) Add(host string, h fasthttp.RequestHandler)

Add add host Handler

func (HostSwitch) Handler

func (p HostSwitch) Handler(ctx *fasthttp.RequestCtx)

Handler for processing incoming requests.

type Proxy

type Proxy struct {
	MaxConns int32
	Conns    int32
	Name     string
	Host     []byte
	Fails    int32
	// contains filtered or unexported fields
}

func NewProxyClient

func NewProxyClient(to *Target) (*Proxy, error)

func (Proxy) Available

func (p Proxy) Available() bool

func (*Proxy) Do

func (p *Proxy) Do(req *fasthttp.Request, resp *fasthttp.Response) (err error)

func (*Proxy) Down

func (p *Proxy) Down() bool

func (Proxy) Full

func (p Proxy) Full() bool

Full checks whether the upstream host has reached its maximum connections

func (*Proxy) Handler

func (p *Proxy) Handler(ctx *fasthttp.RequestCtx) (err error)

func (*Proxy) HealthCheck

func (p *Proxy) HealthCheck()

func (Proxy) StatusOK

func (p Proxy) StatusOK() bool

type Target

type Target struct {
	Name     string `json:"name,omitempty"`
	URL      string `json:"url"`
	MaxConns int    `json:"max_conns"`
	Status   string `json:"status"`
	Host     string `json:"host"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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