httpd

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWriteTimeout      = time.Second
	DefaultReadTimeout       = time.Second
	DefaultReadHeaderTimeout = time.Second
	DefaultIdleTimeout       = time.Second
)
View Source
const DaemonTypeHttpd boot.DaemonType = "httpd"

Variables

This section is empty.

Functions

func Handle

func Handle(pattern string, handler http.Handler)

func HandleAPI

func HandleAPI(pattern string, handler APIHandler)

func HandleFunc

func HandleFunc(pattern string, handler http.HandlerFunc)

func HandleREST

func HandleREST(pattern string, handler RESTHandler)

func HandleRaw

func HandleRaw(pattern string, handler RawHandler)

func RegisterMiddleware

func RegisterMiddleware(mf ...MiddlewareFunc)

RegisterMiddleware must called before Handle func below

func RestRecoverMiddleware

func RestRecoverMiddleware(next http.Handler) http.Handler

Types

type APIHandler

type APIHandler func(http.ResponseWriter, *http.Request) interface{}

func (APIHandler) Handle

func (ah APIHandler) Handle(w http.ResponseWriter, r *http.Request) interface{}

func (APIHandler) ServeHTTP

func (ah APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Cfg

type Cfg struct {
	Addr              string        `` /* 145-byte string literal not displayed */
	WriteTimeout      time.Duration `` /* 183-byte string literal not displayed */
	ReadTimeout       time.Duration `` /* 251-byte string literal not displayed */
	ReadHeaderTimeout time.Duration `` /* 176-byte string literal not displayed */
	IdleTimeout       time.Duration `` /* 206-byte string literal not displayed */
}

func NewCfg

func NewCfg() *Cfg

type Httpd

type Httpd struct {
	runner.Runner
	plugin.Plugin
	*Cfg
	// contains filtered or unexported fields
}

func H added in v0.1.4

func H() *Httpd

func New

func New() *Httpd

func (*Httpd) AppendError

func (h *Httpd) AppendError(err ...error)

func (*Httpd) GetCfg

func (h *Httpd) GetCfg() interface{}

func (*Httpd) RegisterMiddleware

func (h *Httpd) RegisterMiddleware(mf ...MiddlewareFunc)

func (*Httpd) Start

func (h *Httpd) Start() error

func (*Httpd) Stop

func (h *Httpd) Stop() error

func (*Httpd) Type

func (h *Httpd) Type() interface{}

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RESTHandler

type RESTHandler func(http.ResponseWriter, *http.Request) interface{}

func (RESTHandler) Handle

func (rh RESTHandler) Handle(w http.ResponseWriter, r *http.Request) interface{}

func (RESTHandler) ServeHTTP

func (rh RESTHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RawHandler

type RawHandler func(http.ResponseWriter, *http.Request) []byte

func (RawHandler) Handle

func (rh RawHandler) Handle(w http.ResponseWriter, r *http.Request) []byte

func (RawHandler) ServeHTTP

func (rh RawHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Resp

type Resp struct {
	Code RespCode    `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type RespCode

type RespCode int
const (
	RespCodeOk   RespCode = 0
	RespCodeFail RespCode = 1
)

Jump to

Keyboard shortcuts

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