exthttp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer added in v0.2.0

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

HTTPServer is our exthttp server.

func NewHTTPServer added in v0.2.0

func NewHTTPServer(handler http.Handler, logger *log.Logger, opts ...OptionFunc) *HTTPServer

NewHTTPServer create a new HTTPServer instance.

func (*HTTPServer) Run added in v0.2.0

func (hs *HTTPServer) Run(g *run.Group, statusProber prober.Probe)

Run start http server with run group.

func (*HTTPServer) Shutdown added in v0.2.0

func (hs *HTTPServer) Shutdown(err error)

Shutdown shutdown the http server if gracePeriod set, it will shutdown gracefully.

func (*HTTPServer) Start added in v0.2.0

func (hs *HTTPServer) Start() error

Start listen and serve http server.

type MuxServer

type MuxServer struct {
	*HTTPServer
	// contains filtered or unexported fields
}

MuxServer 简单的 http mux server 一般用来挂载 prometheus 和 pprof. MuxServer is a simple http mux server.

func NewMuxServer

func NewMuxServer(logger *log.Logger, opts ...OptionFunc) *MuxServer

NewMuxServer crate a new MuxServer instance.

func (*MuxServer) Handle

func (ms *MuxServer) Handle(pattern string, handler http.Handler)

Handle add handler to mux server.

func (*MuxServer) HandleFunc

func (ms *MuxServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

HandleFunc add handle function to mux server.

func (*MuxServer) RegisterLogControl

func (ms *MuxServer) RegisterLogControl(handler http.Handler)

RegisterLogControl register log level control routes.

func (*MuxServer) RegisterMetrics

func (ms *MuxServer) RegisterMetrics(g prometheus.Gatherer)

RegisterMetrics register metrics route.

func (*MuxServer) RegisterProber

func (ms *MuxServer) RegisterProber(p *prober.HTTPProbe)

RegisterProber register liveness(healthy) and readiness(ready) routes.

func (*MuxServer) RegisterProfiler

func (ms *MuxServer) RegisterProfiler()

RegisterProfiler register pprof routes.

func (*MuxServer) RunGroup

func (ms *MuxServer) RunGroup(g *run.Group)

RunGroup start server with run group.

type Option

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

Option is server options.

type OptionFunc

type OptionFunc func(option *Option)

OptionFunc is option handler type.

func WithGracePeriod

func WithGracePeriod(gracePeriod time.Duration) OptionFunc

WithGracePeriod set grace shutdown period option.

func WithListen

func WithListen(listen string) OptionFunc

WithListen set the listen option.

func WithServiceName

func WithServiceName(name string) OptionFunc

WithServiceName set the service option.

Jump to

Keyboard shortcuts

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