srv

package
v0.0.0-...-a0bb070 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoServerFound = errors.New("no server found")
)

Functions

func CopyRequestHeaders

func CopyRequestHeaders(r *http.Request, dst *http.Request)

func CopyResponseHeaders

func CopyResponseHeaders(w http.ResponseWriter, src *http.Response)

func DumpGoroutinesStackTrace

func DumpGoroutinesStackTrace(pid int)

func GetLogger

func GetLogger(r *http.Request) *zap.Logger

func GetVars

func GetVars(r *http.Request) map[string]string

func LogPanics

func LogPanics(logger *zap.Logger, msg string)

func NewCustomWriter

func NewCustomWriter(w http.ResponseWriter,
	f func(w http.ResponseWriter, status int) int) http.ResponseWriter

NewCustomWriter creates an http.ResponseWriter wrapper that calls your function on WriteHeader.

func NewRouter

func NewRouter() *router

func RetryListen

func RetryListen(ip string, port int) (net.Listener, error)

func RunDaemon

func RunDaemon(initDaemon DaemonConstructor, flags *flag.FlagSet) error

func RunServers

func RunServers(initServer ServerConstructor, flags *flag.FlagSet) error

func SetLogger

func SetLogger(r *http.Request, l *zap.Logger) *http.Request

func SetVars

func SetVars(r *http.Request, v map[string]string) *http.Request

func Split2

func Split2(path string, sep string) (string, string)

Split a string in twain on sep. Doing it this way over strings.Split*() saves allocating a slice.

func ValidateRequest

func ValidateRequest(w http.ResponseWriter, r *http.Request) bool

Types

type Daemon

type Daemon interface {
	Run()
	RunForever()
}

type DaemonConstructor

type DaemonConstructor func(conf.Config, *flag.FlagSet) (Daemon, error)

type KeyType

type KeyType int

type Server

type Server interface {
	Start() error
	Shutdown(ctx context.Context) error
	Close() error
	Finalize()
}

type ServerConstructor

type ServerConstructor func(conf.Config, *flag.FlagSet) (Server, error)

type WebWriter

type WebWriter struct {
	http.ResponseWriter
	Status          int
	ResponseStarted bool
}

ResponseWriter that saves its status - used for logging.

func (WebWriter) Hijack

func (w WebWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*WebWriter) Response

func (w *WebWriter) Response() (bool, int)

func (*WebWriter) WriteHeader

func (w *WebWriter) WriteHeader(status int)

type WebWriterInterface

type WebWriterInterface interface {
	http.ResponseWriter
	Response() (bool, int)
}

Jump to

Keyboard shortcuts

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