httputils

package
v0.0.0-...-bc5839e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolValue

func BoolValue(r *http.Request, k string) bool

BoolValue transforms a form value in different formats into a boolean type.

func GenTLSConfig

func GenTLSConfig(key, cert, ca string) (*tls.Config, error)

GenTLSConfig returns a tls config object according to inputting parameters.

func NewHTTPClient

func NewHTTPClient(u *url.URL, tlsConfig *tls.Config, dialTimeout, cliTimeout time.Duration) *http.Client

NewHTTPClient creates a http client using url and tlsconfig

func ParseHost

func ParseHost(host string) (*url.URL, string, string, error)

ParseHost inputs a host address string, and output four type: url.URL, basePath, address without scheme and an error.

Types

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError represents an HTTP error which contains potential status code. For API layer, daemon side should return error message and using correct status code to construct response when an error happens in handling requests.

func NewHTTPError

func NewHTTPError(err error, code int) HTTPError

NewHTTPError returns a brand new HTTPError with input message and status code

func (HTTPError) Code

func (err HTTPError) Code() int

Code returns status code field of HTTPError

func (HTTPError) Error

func (err HTTPError) Error() string

Error returns Message field of HTTPError

Jump to

Keyboard shortcuts

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