dutil

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func ListenAndServeHTTPWithContext(ctx context.Context, server *http.Server) error

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

func ServeHTTPWithContext(ctx context.Context, server *http.Server, listener net.Listener) error

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.

Jump to

Keyboard shortcuts

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