Documentation
¶
Index ¶
- func ListenAndServeHTTPSWithContext(ctx context.Context, server *http.Server, certFile, keyFile string) error
- func ListenAndServeHTTPWithContext(ctx context.Context, server *http.Server) error
- func PanicToError(rec interface{}) error
- func ServeHTTPSWithContext(ctx context.Context, server *http.Server, ln net.Listener, ...) error
- func ServeHTTPWithContext(ctx context.Context, server *http.Server, listener net.Listener) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServeHTTPSWithContext ¶
func ListenAndServeHTTPSWithContext(ctx context.Context, server *http.Server, certFile, keyFile string) error
ListenAndServeHTTPSWithContext runs server.ListenAndServeTLS() on an http.Server, but properly calls server.Shutdown when the Context is canceled.
It obeys hard/soft cancellation as implemented by dcontext.WithSoftness; it calls server.Shutdown() when the soft Context is canceled, and the hard Context being canceled causes the .Shutdown() to hurry along and kill any live requests and return, instead of waiting for them to be completed gracefully.
func ListenAndServeHTTPWithContext ¶
ListenAndServeHTTPWithContext runs server.ListenAndServe() on an http.Server, but properly calls server.Shutdown when the Context is canceled.
It obeys hard/soft cancellation as implemented by dcontext.WithSoftness; it calls server.Shutdown() when the soft Context is canceled, and the hard Context being canceled causes the .Shutdown() to hurry along and kill any live requests and return, instead of waiting for them to be completed gracefully.
func PanicToError ¶
func PanicToError(rec interface{}) error
PanicToError takes an arbitrary object returned from recover(), and returns an appropriate error.
If the input is nil, then nil is returned.
If the input is an error returned from a previus call to PanicToError(), then it is returned verbatim.
If the input is an error, it is wrapped with the message "PANIC:" and has a stack trace attached to it.
If the input is anything else, it is formatted with "%+v" and returned as an error with a stack trace attached.
func ServeHTTPSWithContext ¶
func ServeHTTPSWithContext(ctx context.Context, server *http.Server, ln net.Listener, certFile, keyFile string) error
ServeHTTPSWithContext runs server.ServeTLS() on an http.Server, but properly calls server.Shutdown when the Context is canceled.
It obeys hard/soft cancellation as implemented by dcontext.WithSoftness; it calls server.Shutdown() when the soft Context is canceled, and the hard Context being canceled causes the .Shutdown() to hurry along and kill any live requests and return, instead of waiting for them to be completed gracefully.
func ServeHTTPWithContext ¶
ServeHTTPWithContext(ln) runs server.Serve(ln) on an http.Server, but properly calls server.Shutdown when the Context is canceled.
It obeys hard/soft cancellation as implemented by dcontext.WithSoftness; it calls server.Shutdown() when the soft Context is canceled, and the hard Context being canceled causes the .Shutdown() to hurry along and kill any live requests and return, instead of waiting for them to be completed gracefully.
Types ¶
This section is empty.