httpx

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 13 Imported by: 0

README

Build Status Code Coverage Go Report Card GoDoc

Documentation

Index

Constants

View Source
const (
	HeaderAccept        = "Accept"
	HeaderAuthorization = "Authorization"
	HeaderContentLength = "Content-Length"
	HeaderContentType   = "Content-Type"
	HeaderHost          = "Host"
	HeaderOrigin        = "Origin"
	HeaderReferer       = "Referer"
	HeaderUserAgent     = "User-Agent"

	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlMaxAgeSeconds    = "Access-Control-Max-Age"

	HeaderXForwardedFor = "X-Forwarded-For"
)
View Source
const (
	ContentTypeOctetStream    = "application/octet-stream"
	ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
)
View Source
const (
	ContentTypeHeader   = "Content-Type"
	MIMEApplicationJSON = "application/json; charset=utf-8"
	MIMETextPlain       = "text/plain; charset=utf-8"
)

Variables

View Source
var DefaultShutdownTimeout = time.Second

Functions

func CalculateRequestSize

func CalculateRequestSize(request *http.Request) int64

func PanicHandler

func PanicHandler(response http.ResponseWriter, _ *http.Request, err interface{})

func ReadClientIPAddress

func ReadClientIPAddress(request *http.Request, customHeader string) string

func ReadHeader

func ReadHeader(request *http.Request, canonicalHeaderName string) string

func WriteError

func WriteError(response http.ResponseWriter, err error, statusCode int)

func WriteErrorMessage

func WriteErrorMessage(response http.ResponseWriter, message string, statusCode int)

func WriteHeader

func WriteHeader(request *http.Request, canonicalHeaderName string, value string)

func WriteJSON

func WriteJSON(contents interface{}, response http.ResponseWriter)

func WritePrettyJSON

func WritePrettyJSON(contents interface{}, response http.ResponseWriter)

func WriteRequest

func WriteRequest(response http.ResponseWriter, request *http.Request, message string, status int)

func WriteResponse

func WriteResponse(response http.ResponseWriter, err error)

func WriteResult

func WriteResult(response http.ResponseWriter, statusCode int)

Types

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(listenAddress string, handler http.Handler) *HTTPServer

func (*HTTPServer) Close

func (this *HTTPServer) Close()

func (*HTTPServer) Listen

func (this *HTTPServer) Listen()

func (*HTTPServer) Shutdown

func (this *HTTPServer) Shutdown(timeout time.Duration) error

func (*HTTPServer) WithTLS

func (this *HTTPServer) WithTLS(certificatePEM string, tlsConfig *tls.Config) *HTTPServer

func (*HTTPServer) WithTLSFiles

func (this *HTTPServer) WithTLSFiles(cert, key string, tlsConfig *tls.Config) *HTTPServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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