server

package
v0.0.0-...-4c85db1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DurianName    = "durian"
	DurianVersion = "0.0.1"
)
View Source
const (
	FastHTTPServerType  = "fasthttp"
	RequestIDHeaderName = "rid"
)
View Source
const (
	LogMiddlewareName    = "log"
	UUIDMiddlewareName   = "uuid"
	RouterMiddlewareName = "router"
)
View Source
const (
	DirectiveProxy    = "proxy"
	DirectiveHeader   = "header"
	DirectiveTimeout  = "timeout"
	DirectiveStatic   = "static"
	DirectiveRewrite  = "rewrite"
	DirectiveStatus   = "status"
	DirectiveResponse = "response"
	DirectiveGzip     = "gzip"
	DirectiveNotFound = "not_found"
	DirectiveLog      = "log"
	DirectiveRouter   = "router"
	DirectiveFastCgi  = "fastcgi"
	DirectiveUpstream = "upstream"
)

Variables

This section is empty.

Functions

func GetStdCtx

func GetStdCtx(reqCtx *fasthttp.RequestCtx) context.Context

Types

type Backend

type Backend struct {
	Network string
	Addr    string
	Weight  int
	Backup  bool
}

type FastServer

type FastServer struct {
	*fasthttp.Server
	Addr string
}

func NewFastServer

func NewFastServer(cfg ServerConfig) *FastServer

func (*FastServer) Address

func (s *FastServer) Address() string

func (*FastServer) Listen

func (s *FastServer) Listen() (net.Listener, error)

func (*FastServer) ListenPacket

func (s *FastServer) ListenPacket() (net.PacketConn, error)

func (*FastServer) Serve

func (s *FastServer) Serve(ln net.Listener) error

func (*FastServer) ServePacket

func (s *FastServer) ServePacket(net.PacketConn) error

func (*FastServer) Stop

func (s *FastServer) Stop() error

func (*FastServer) WrapListener

func (s *FastServer) WrapListener(ln net.Listener) net.Listener

type GzipConfig

type GzipConfig struct {
	Open  bool
	Level int
}

type KVTuple

type KVTuple struct {
	K, V string
}

type LocationMatcher

type LocationMatcher interface {
	Match(uri []byte) bool
}

func NewCombineMatcher

func NewCombineMatcher(shouldMatch LocationMatcher, exclude LocationMatcher) LocationMatcher

func NewLocationMatcher

func NewLocationMatcher(firstLine []string) (LocationMatcher, error)

type Middleware

type Middleware func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

type NotFoundConfig

type NotFoundConfig struct {
	StatusCode  int
	File        string
	ContentType string
	Body        string
}

type ServerConfig

type ServerConfig struct {
	Root                          string
	Addr                          string
	Name                          string
	Concurrency                   int
	DisableKeepalive              bool
	ReadBufferSize                int
	WriteBufferSize               int
	ReadTimeout                   time.Duration
	WriteTimeout                  time.Duration
	MaxConnsPerIP                 int
	MaxRequestsPerConn            int
	MaxKeepaliveDuration          time.Duration
	TCPKeepalive                  bool
	TCPKeepalivePeriod            time.Duration
	MaxRequestBodySize            int
	DisableHeaderNamesNormalizing bool
	NoDefaultServerHeader         bool
	NoDefaultContentType          bool
	Gzip                          GzipConfig
	NotFound                      NotFoundConfig

	RequestIDName string
	// contains filtered or unexported fields
}

ServerConfig stores the configuration for fasthttp.Server

func GetConfig

func GetConfig(c *caddy.Controller) *ServerConfig

func (*ServerConfig) AddMiddleware

func (cfg *ServerConfig) AddMiddleware(m Middleware)

func (*ServerConfig) AddNamedMiddleware

func (cfg *ServerConfig) AddNamedMiddleware(name string, m Middleware)

type StorageKey

type StorageKey int
const (
	UpstreamKey StorageKey = iota
	ServerNameKey
	DocRootKey
)

type Upstream

type Upstream struct {
	Name     string
	Backends []Backend
}

Jump to

Keyboard shortcuts

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