httpserver

package
v0.0.0-...-b579be4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT, MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustListenAndServeHTTP

func MustListenAndServeHTTP(server *http.Server, config Config, app http.Handler)

MustListenAndServeHTTP listen and serve http server with given server,config and handler. Panic if any error raised.

func MustServeHTTP

func MustServeHTTP(server *http.Server, l net.Listener, app http.Handler)

MustServeHTTP serve http server with given server,listener and handler. Panic if any error raised.

func RecoverMiddleware

func RecoverMiddleware(logger *log.Logger) func(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

RecoverMiddleware create recover middleware with given logger.

func ShutdownHTTP

func ShutdownHTTP(Server *http.Server)

ShutdownHTTP shutdown http server.

func ShutdownHTTPWithTimeout

func ShutdownHTTPWithTimeout(Server *http.Server, Timeout time.Duration)

ShutdownHTTPWithTimeout shutdown http server ith given timeout.

func WithContextShutdown

func WithContextShutdown(ctx context.Context, Server *http.Server)

WithContextShutdown shutdown http server ith given context.

Types

type Config

type Config struct {
	//Net net interface,"tcp" for example.
	Net string
	//Addr network addr.
	Addr string
	//BaseURL http scheme and host."http://127.0.0.1:8000" for example.
	BaseURL string
	//ReadTimeoutInSecond http conn read time out.
	ReadTimeoutInSecond int64
	//ReadTimeoutInSecond http conn read Header time out.
	ReadHeaderTimeoutInSecond int64
	//WriteTimeoutInSecond http conn write time out.
	WriteTimeoutInSecond int64
	//IdleTimeoutInSecond conn idle time out.
	IdleTimeoutInSecond int64
	//MaxHeaderBytes max header length in bytes.
	MaxHeaderBytes int
}

Config http server config.

func (*Config) Listen

func (c *Config) Listen() (net.Listener, error)

Listen listen net and addr in config. Return net listener and any error if raised.

func (*Config) MustListen

func (c *Config) MustListen() net.Listener

MustListen listen net and addr in config. Return net listener. Panic if any error raised.

func (*Config) Server

func (c *Config) Server() *http.Server

Server create http server with config.

Jump to

Keyboard shortcuts

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