web

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(http.ResponseWriter, *http.Request)

func (Handler) ServeHTTP

func (f Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP calls f(w, r).

type Option

type Option func(*Options)

func CloseTimeout

func CloseTimeout(t time.Duration) Option

Deadline to wait for closing. Default is 5s

func IdleTimeout

func IdleTimeout(t time.Duration) Option

Maximum amount of time to wait for the next request. Default is 60s

func ListenIp

func ListenIp(ip string) Option

Ip of listening. Default is "0.0.0.0"

func ListenPort

func ListenPort(port int) Option

Port of listening. Default is 5050

func ReadTimeout

func ReadTimeout(t time.Duration) Option

Maximum duration for reading the entire request. Default is 15s

func WriteTimeout

func WriteTimeout(t time.Duration) Option

Maximum duration before timing out writes of the response. Default is 15s

type Options

type Options struct {
	ListenIp     string
	ListenPort   int
	WriteTimeout time.Duration
	ReadTimeout  time.Duration
	IdleTimeout  time.Duration
	CloseTimeout time.Duration
}

type WebServer

type WebServer struct {
	// contains filtered or unexported fields
}

func NewWebServer

func NewWebServer(opts ...Option) *WebServer

func (*WebServer) OnDestroy

func (w *WebServer) OnDestroy()

func (*WebServer) OnInit

func (w *WebServer) OnInit()

func (*WebServer) OnRun

func (w *WebServer) OnRun(closeSig chan bool)

func (*WebServer) PrefixRoute

func (w *WebServer) PrefixRoute(path string, f http.Handler)

func (*WebServer) Route

func (w *WebServer) Route(path string, f Handler)

Jump to

Keyboard shortcuts

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