Documentation
¶
Index ¶
- Constants
- func ErrorFunc(w http.ResponseWriter, r *http.Request, status int)
- func JoinNetworkAddress(network, host, port string) string
- func Listen(addr interface{}) (net.Listener, error)
- func LoadConfigFile(confFile string) map[string]interface{}
- func SaveConfigFile(conf map[string]interface{}) error
- func SplitNetworkAddress(a string) (network, host, port string, err error)
- func WriteTextResp(w http.ResponseWriter, status int, body string)
- type Core
- type CtxKey
- type HandlerError
- type NetworkAddress
Constants ¶
const ErrorCtxKey = CtxKey("handler_chain_error")
ErrorCtxKey is the context key to use when storing an error (for use with context.Context).
Variables ¶
This section is empty.
Functions ¶
func JoinNetworkAddress ¶
JoinNetworkAddress combines network, host, and port into a single address string of the form accepted by ParseNetworkAddress(). For unix sockets, the network should be "unix" (or "unixgram" or "unixpacket") and the path to the socket should be given as the host parameter.
func LoadConfigFile ¶
LoadConfigFile load yml config
func SaveConfigFile ¶
func SplitNetworkAddress ¶
SplitNetworkAddress splits a into its network, host, and port components. Note that port may be a port range (:X-Y), or omitted for unix sockets.
func WriteTextResp ¶
func WriteTextResp(w http.ResponseWriter, status int, body string)
Types ¶
type HandlerError ¶
type HandlerError struct { Err error // the original error value and message StatusCode int // the HTTP status code to associate with this error ID string // generated; for identifying this error in logs Trace string // produced from call stack }
HandlerError is a serializable representation of an error from within an HTTP handler.
func Error ¶
func Error(statusCode int, err error) HandlerError
Error is a convenient way for a Handler to populate the essential fields of a HandlerError. If err is itself a HandlerError, then any essential fields that are not set will be populated.
func (HandlerError) Error ¶
func (e HandlerError) Error() string
type NetworkAddress ¶
NetworkAddress contains the individual components for a parsed network address of the form accepted by ParseNetworkAddress(). Network should be a network value accepted by Go's net package. Port ranges are given by [StartPort, EndPort].
func ParseNetworkAddress ¶
func ParseNetworkAddress(addr string) (NetworkAddress, error)
ParseNetworkAddress parses addr into its individual components. The input string is expected to be of the form "network/host:port-range" where any part is optional. The default network, if unspecified, is tcp. Port ranges are inclusive.
Network addresses are distinct from URLs and do not use URL syntax.
func (NetworkAddress) IsUnixNetwork ¶
func (na NetworkAddress) IsUnixNetwork() bool
IsUnixNetwork returns true if na.Network is unix, unixgram, or unixpacket.
func (NetworkAddress) JoinHostPort ¶
func (na NetworkAddress) JoinHostPort(offset uint) string
JoinHostPort is like net.JoinHostPort, but where the port is StartPort + offset.
func (NetworkAddress) PortRangeSize ¶
func (na NetworkAddress) PortRangeSize() uint
PortRangeSize returns how many ports are in pa's port range. Port ranges are inclusive, so the size is the difference of start and end ports plus one.
func (NetworkAddress) String ¶
func (na NetworkAddress) String() string
String reconstructs the address string to the form expected by ParseNetworkAddress(). If the address is a unix socket, any non-zero port will be dropped.