webserver

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableExpVarEndpoints

func EnableExpVarEndpoints(ws WebServer)

EnableExpVarEndpoints exposes expvar http endpoints.

func EnablePprofEndpoints

func EnablePprofEndpoints(ws WebServer)

EnablePprofEndpoints exposes pprof http endpoints.

func SetDefaultWebServer

func SetDefaultWebServer(ws WebServer) error

SetDefaultWebServer sets default server instance is not thread-safe

Types

type SimpleWebServer

type SimpleWebServer struct {
	*http.Server
	*http.ServeMux
	// contains filtered or unexported fields
}

SimpleWebServer is naive implementation of WebServer. is not thread-safe

func NewSimpleWebServer

func NewSimpleWebServer(addr string) *SimpleWebServer

NewSimpleWebServer builds SimpleWebServer.

func (*SimpleWebServer) Serve

func (sw *SimpleWebServer) Serve() error

Serve starts server. TODO: handle errors properly

func (*SimpleWebServer) Shutdown

func (sw *SimpleWebServer) Shutdown(ctx context.Context) error

Shutdown stops running server.

type WebServer

type WebServer interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	Serve() error
	Shutdown(ctx context.Context) error
}

WebServer defines web-server interface.

var DefaultWebServer WebServer

Jump to

Keyboard shortcuts

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