Documentation
¶
Index ¶
- func MustListenAndServeHTTP(server *http.Server, config Config, app http.Handler)
- func MustServeHTTP(server *http.Server, l net.Listener, app http.Handler)
- func RecoverMiddleware(logger *log.Logger) func(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
- func ShutdownHTTP(Server *http.Server)
- func ShutdownHTTPWithTimeout(Server *http.Server, Timeout time.Duration)
- func WithContextShutdown(ctx context.Context, Server *http.Server)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustListenAndServeHTTP ¶
MustListenAndServeHTTP listen and serve http server with given server,config and handler. Panic if any error raised.
func MustServeHTTP ¶
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 ShutdownHTTPWithTimeout ¶
ShutdownHTTPWithTimeout shutdown http server ith given timeout.
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 ¶
Listen listen net and addr in config. Return net listener and any error if raised.
func (*Config) MustListen ¶
MustListen listen net and addr in config. Return net listener. Panic if any error raised.
Click to show internal directories.
Click to hide internal directories.