Documentation ¶
Index ¶
- Variables
- func AddXU(header Header, name []byte, value []byte)
- func DecodeParams(params Params, dst interface{}) (err error)
- func DeviceIp(ctx context.Context) (ip []byte)
- func GetXU(header Header, name []byte) (value []byte)
- func ObjectParams(params Params) objects.Object
- func ReleaseCookie(c *Cookie)
- func ReleaseHeader(h Header)
- func ReleaseResultResponseWriter(w *ResultResponseWriter)
- func SetXU(header Header, name []byte, value []byte)
- func ValuesXU(header Header, name []byte) (value [][]byte)
- func WithRequest(ctx context.Context, r Request) context.Context
- func WithRequestHeader(ctx context.Context, header Header) context.Context
- func WithResponse(ctx context.Context, w ResponseWriter) context.Context
- type AcceptEncoding
- type AcceptEncodings
- func (encodings AcceptEncodings) Add(name []byte, quality float64) AcceptEncodings
- func (encodings AcceptEncodings) Get(name []byte) (quality float64, has bool)
- func (encodings AcceptEncodings) Len() int
- func (encodings AcceptEncodings) Less(i, j int) bool
- func (encodings AcceptEncodings) Swap(i, j int)
- func (encodings AcceptEncodings) WriteTo(header Header)
- type Client
- type Config
- func (config *Config) GetPort() (port int, err error)
- func (config *Config) GetTLS() (tls ssl.Config, err error)
- func (config *Config) HandlerConfig(name string) (handler configures.Config, err error)
- func (config *Config) MiddlewareConfig(name string) (middleware configures.Config, err error)
- func (config *Config) OptionsConfig() (options configures.Config, err error)
- type Cookie
- func (c *Cookie) Domain() []byte
- func (c *Cookie) Expire() time.Time
- func (c *Cookie) HTTPOnly() bool
- func (c *Cookie) Key() []byte
- func (c *Cookie) MaxAge() int
- func (c *Cookie) Path() []byte
- func (c *Cookie) Reset()
- func (c *Cookie) SameSite() CookieSameSite
- func (c *Cookie) Secure() bool
- func (c *Cookie) SetDomain(domain []byte)
- func (c *Cookie) SetExpire(expire time.Time)
- func (c *Cookie) SetHTTPOnly(httpOnly bool)
- func (c *Cookie) SetKey(key []byte)
- func (c *Cookie) SetMaxAge(seconds int)
- func (c *Cookie) SetPath(path []byte)
- func (c *Cookie) SetSameSite(mode CookieSameSite)
- func (c *Cookie) SetSecure(secure bool)
- func (c *Cookie) SetValue(value []byte)
- func (c *Cookie) Value() []byte
- type CookieSameSite
- type Dialer
- type Handler
- type HandlerFunc
- type Header
- type Marshal
- type Middleware
- type MiddlewareOptions
- type Middlewares
- type Mux
- type MuxHandler
- type MuxHandlerOptions
- type Options
- type Params
- type Request
- type ResponseWriter
- type ResultResponseWriter
- func (w *ResultResponseWriter) Body() []byte
- func (w *ResultResponseWriter) BodyLen() int
- func (w *ResultResponseWriter) Failed(cause error)
- func (w *ResultResponseWriter) Header() (h Header)
- func (w *ResultResponseWriter) ResetBody()
- func (w *ResultResponseWriter) SetStatus(status int)
- func (w *ResultResponseWriter) Status() int
- func (w *ResultResponseWriter) Succeed(v any)
- func (w *ResultResponseWriter) Write(body []byte) (int, error)
- func (w *ResultResponseWriter) WriteDeadline() time.Time
- func (w *ResultResponseWriter) WriteTimeout() time.Duration
- type Server
- type TLSConfig
- type Transport
- type WriteBuffer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ContentTypeHeaderName = []byte("Content-Type") ContentTypeJsonHeaderValue = []byte("application/json") ContentTypeTextHeaderValue = []byte("text/plain") ContentTypeAvroHeaderValue = []byte("application/avro") ContentLengthHeaderName = []byte("Content-Length") AuthorizationHeaderName = []byte("Authorization") CookieHeaderName = []byte("Cookie") ConnectionHeaderName = []byte("Connection") UpgradeHeaderName = []byte("Upgrade") CloseHeaderValue = []byte("close") AcceptEncodingHeaderName = []byte("Accept-Encoding") ContentEncodingHeaderName = []byte("Content-Encoding") ClearSiteDataHeaderName = []byte("Clear-Site-Data") CacheControlHeaderName = []byte("Cache-Control") AgeHeaderName = []byte("Age") CacheControlHeaderNoStore = []byte("no-store") CacheControlHeaderNoCache = []byte("no-cache") ETagHeaderName = []byte("ETag") CacheControlHeaderIfNonMatch = []byte("If-None-Match") VaryHeaderName = []byte("Vary") OriginHeaderName = []byte("Origin") AcceptHeaderName = []byte("Accept") AccessControlRequestMethodHeaderName = []byte("Access-Control-Request-Method") AccessControlRequestHeadersHeaderName = []byte("Access-Control-Request-Headers") AccessControlRequestPrivateNetworkHeaderName = []byte("Access-Control-Request-Private-Network") AccessControlAllowOriginHeaderName = []byte("Access-Control-Allow-Origin") AccessControlAllowMethodsHeaderName = []byte("Access-Control-Allow-Methods") AccessControlAllowHeadersHeaderName = []byte("Access-Control-Allow-Headers") AccessControlAllowCredentialsHeaderName = []byte("Access-Control-Allow-Credentials") AccessControlAllowPrivateNetworkHeaderName = []byte("Access-Control-Allow-Private-Network") AccessControlMaxAgeHeaderName = []byte("Access-Control-Max-Age") AccessControlExposeHeadersHeaderName = []byte("Access-Control-Expose-Headers") XRequestedWithHeaderName = []byte("X-Requested-With") TrueClientIpHeaderName = []byte("True-Client-Ip") XRealIpHeaderName = []byte("X-Real-IP") XForwardedForHeaderName = []byte("X-Forwarded-For") RequestIdHeaderName = []byte("X-Fns-Request-Id") SignatureHeaderName = []byte("X-Fns-Signature") EndpointIdHeaderName = []byte("X-Fns-Endpoint-Id") EndpointVersionHeaderName = []byte("X-Fns-Endpoint-Version") RequestTimeoutHeaderName = []byte("X-Fns-Request-Timeout") RequestVersionsHeaderName = []byte("X-Fns-Request-Version") HandleLatencyHeaderName = []byte("X-Fns-Handle-Latency") DeviceIdHeaderName = []byte("X-Fns-Device-Id") DeviceIpHeaderName = []byte("X-Fns-Device-Ip") DeprecatedHeaderName = []byte("X-Fns-Deprecated") ResponseRetryAfterHeaderName = []byte("Retry-After") UserHeaderNamePrefix = []byte("XU-") )
View Source
var ( MethodGet = []byte(http.MethodGet) MethodPost = []byte(http.MethodPost) )
View Source
var (
ErrTooBigRequestBody = errors.New(http.StatusRequestEntityTooLarge, "***TOO LARGE BODY***", "fns: request body is too large")
)
Functions ¶
func DecodeParams ¶
func ObjectParams ¶ added in v1.2.0
func ReleaseCookie ¶
func ReleaseCookie(c *Cookie)
func ReleaseHeader ¶
func ReleaseHeader(h Header)
func ReleaseResultResponseWriter ¶
func ReleaseResultResponseWriter(w *ResultResponseWriter)
func WithRequestHeader ¶ added in v1.1.3
func WithResponse ¶
func WithResponse(ctx context.Context, w ResponseWriter) context.Context
Types ¶
type AcceptEncoding ¶ added in v1.2.12
type AcceptEncodings ¶ added in v1.2.12
type AcceptEncodings []AcceptEncoding
func GetAcceptEncodings ¶ added in v1.2.12
func GetAcceptEncodings(header Header) (encodings AcceptEncodings)
func (AcceptEncodings) Add ¶ added in v1.2.21
func (encodings AcceptEncodings) Add(name []byte, quality float64) AcceptEncodings
func (AcceptEncodings) Get ¶ added in v1.2.12
func (encodings AcceptEncodings) Get(name []byte) (quality float64, has bool)
func (AcceptEncodings) Len ¶ added in v1.2.12
func (encodings AcceptEncodings) Len() int
func (AcceptEncodings) Less ¶ added in v1.2.12
func (encodings AcceptEncodings) Less(i, j int) bool
func (AcceptEncodings) Swap ¶ added in v1.2.12
func (encodings AcceptEncodings) Swap(i, j int)
func (AcceptEncodings) WriteTo ¶ added in v1.2.21
func (encodings AcceptEncodings) WriteTo(header Header)
type Config ¶
type Config struct { Port int `json:"port,omitempty" yaml:"port,omitempty"` TLS *TLSConfig `json:"tls,omitempty" yaml:"tls,omitempty"` Options json.RawMessage `json:"options,omitempty" yaml:"options,omitempty"` Middlewares json.RawMessage `json:"middlewares,omitempty" yaml:"middlewares,omitempty"` Handlers json.RawMessage `json:"handlers,omitempty" yaml:"handlers,omitempty"` }
func (*Config) HandlerConfig ¶
func (config *Config) HandlerConfig(name string) (handler configures.Config, err error)
func (*Config) MiddlewareConfig ¶
func (config *Config) MiddlewareConfig(name string) (middleware configures.Config, err error)
func (*Config) OptionsConfig ¶
func (config *Config) OptionsConfig() (options configures.Config, err error)
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
func AcquireCookie ¶
func AcquireCookie() *Cookie
func (*Cookie) SameSite ¶
func (c *Cookie) SameSite() CookieSameSite
func (*Cookie) SetHTTPOnly ¶
func (*Cookie) SetSameSite ¶
func (c *Cookie) SetSameSite(mode CookieSameSite)
type CookieSameSite ¶
type CookieSameSite int
const ( CookieSameSiteDisabled CookieSameSite = iota CookieSameSiteDefaultMode CookieSameSiteLaxMode CookieSameSiteStrictMode CookieSameSiteNoneMode )
type Handler ¶
type Handler interface {
Handle(w ResponseWriter, r Request)
}
type HandlerFunc ¶
type HandlerFunc func(ResponseWriter, Request)
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(w ResponseWriter, r Request)
type Header ¶
type Header interface { Add(key []byte, value []byte) Set(key []byte, value []byte) Get(key []byte) []byte Del(key []byte) Values(key []byte) [][]byte Foreach(fn func(key []byte, values [][]byte)) Len() int Reset() }
func AcquireHeader ¶
func AcquireHeader() Header
type Marshal ¶ added in v1.2.12
func GetMarshaler ¶ added in v1.2.21
type Middleware ¶
type MiddlewareOptions ¶
type MiddlewareOptions struct { Log logs.Logger Config configures.Config }
type Middlewares ¶
type Middlewares []Middleware
func WaveMiddlewares ¶
func WaveMiddlewares(log logs.Logger, config Config, middlewares []Middleware) (v Middlewares, err error)
func (Middlewares) Close ¶
func (middlewares Middlewares) Close()
func (Middlewares) Handler ¶
func (middlewares Middlewares) Handler(handler Handler) Handler
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
func (*Mux) Add ¶
func (mux *Mux) Add(handler MuxHandler)
func (*Mux) Handle ¶
func (mux *Mux) Handle(w ResponseWriter, r Request)
type MuxHandler ¶
type MuxHandlerOptions ¶
type MuxHandlerOptions struct { Log logs.Logger Config configures.Config }
type Params ¶
type Request ¶
type Request interface { context.Context TLS() bool TLSConnectionState() *tls.ConnectionState RemoteAddr() []byte Proto() []byte Host() []byte Method() []byte SetMethod(method []byte) Header() Header Cookie(key []byte) (value []byte) SetCookie(key []byte, value []byte) RequestURI() []byte Path() []byte Params() Params FormValue(name []byte) (value []byte) Body() ([]byte, error) SetBody(body []byte) }
func LoadRequest ¶
type ResponseWriter ¶
type ResponseWriter interface { context.Context Status() int SetStatus(status int) SetCookie(cookie *Cookie) Header() Header Succeed(v any) Failed(cause error) Write(body []byte) (int, error) Body() []byte BodyLen() int ResetBody() Hijack(func(ctx context.Context, conn net.Conn, rw *bufio.ReadWriter) (err error)) (async bool, err error) Hijacked() bool WriteTimeout() time.Duration WriteDeadline() time.Time }
func LoadResponseWriter ¶
func LoadResponseWriter(ctx context.Context) ResponseWriter
func TryLoadResponseWriter ¶
func TryLoadResponseWriter(ctx context.Context) (ResponseWriter, bool)
type ResultResponseWriter ¶
type ResultResponseWriter struct {
// contains filtered or unexported fields
}
func AcquireResultResponseWriter ¶
func AcquireResultResponseWriter(timeout time.Duration, contentType []byte) *ResultResponseWriter
func (*ResultResponseWriter) Body ¶
func (w *ResultResponseWriter) Body() []byte
func (*ResultResponseWriter) BodyLen ¶
func (w *ResultResponseWriter) BodyLen() int
func (*ResultResponseWriter) Failed ¶
func (w *ResultResponseWriter) Failed(cause error)
func (*ResultResponseWriter) Header ¶ added in v1.2.0
func (w *ResultResponseWriter) Header() (h Header)
func (*ResultResponseWriter) ResetBody ¶ added in v1.2.63
func (w *ResultResponseWriter) ResetBody()
func (*ResultResponseWriter) SetStatus ¶
func (w *ResultResponseWriter) SetStatus(status int)
func (*ResultResponseWriter) Status ¶
func (w *ResultResponseWriter) Status() int
func (*ResultResponseWriter) Succeed ¶
func (w *ResultResponseWriter) Succeed(v any)
func (*ResultResponseWriter) WriteDeadline ¶ added in v1.1.1
func (w *ResultResponseWriter) WriteDeadline() time.Time
func (*ResultResponseWriter) WriteTimeout ¶ added in v1.1.1
func (w *ResultResponseWriter) WriteTimeout() time.Duration
type TLSConfig ¶
type TLSConfig struct { // Kind // ACME // SSC(SELF-SIGN-CERT) // DEFAULT Kind string `json:"kind" yaml:"kind,omitempty"` Options json.RawMessage `json:"options" yaml:"options,omitempty"` // contains filtered or unexported fields }
func FixedTLSConfig ¶ added in v1.1.3
type WriteBuffer ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.