Documentation
¶
Index ¶
- Constants
- Variables
- type CheckRedirectFn
- type Client
- type ClientOption
- type ClientRequest
- type ClientRequestOption
- func WithBody(r io.ReadCloser) ClientRequestOption
- func WithClose(v bool) ClientRequestOption
- func WithContentLength(l int64) ClientRequestOption
- func WithForm(form url.Values) ClientRequestOption
- func WithGetBody(f func() (io.ReadCloser, error)) ClientRequestOption
- func WithHeader(name string, values ...string) ClientRequestOption
- func WithHeaders(headers Header) ClientRequestOption
- func WithHost(host string) ClientRequestOption
- func WithMultipartForm(form *multipart.Form) ClientRequestOption
- func WithPostForm(form url.Values) ClientRequestOption
- func WithRemoteAddr(addr string) ClientRequestOption
- func WithRequestURI(uri string) ClientRequestOption
- func WithTrailer(t Header) ClientRequestOption
- func WithTransferEncoding(encodings []string) ClientRequestOption
- type ClientResponse
- type ConnState
- type Cookie
- type CookieJar
- type Dir
- type File
- type FileSystem
- type Flusher
- type HTTP
- type Handler
- type HandlerFunc
- type Header
- type Hijacker
- type MaxBytesError
- type PushOptions
- type Pusher
- type ResponseWriter
- type RoundTripper
- type SameSite
- type Server
- type ServerOption
- func WithAddr(addr string) ServerOption
- func WithBaseContext(f func(net.Listener) context.Context) ServerOption
- func WithConnContext(f func(context.Context, net.Conn) context.Context) ServerOption
- func WithConnState(f func(net.Conn, ConnState)) ServerOption
- func WithDisableGeneralOptionsHandler(v bool) ServerOption
- func WithErrorLog(l *log.Logger) ServerOption
- func WithHandler(handler Handler) ServerOption
- func WithIdleTimeout(t time.Duration) ServerOption
- func WithMaxHeaderBytes(n int) ServerOption
- func WithReadHeaderTimeout(t time.Duration) ServerOption
- func WithReadTimeout(t time.Duration) ServerOption
- func WithTLSConfig(cfg *tls.Config) ServerOption
- func WithTLSNextProto(m map[string]func(*http.Server, *tls.Conn, http.Handler)) ServerOption
- func WithWriteTimeout(t time.Duration) ServerOption
- type ServerRequest
Constants ¶
const ( MethodGet = http.MethodGet MethodHead = http.MethodHead MethodPost = http.MethodPost MethodPut = http.MethodPut MethodPatch = http.MethodPatch MethodDelete = http.MethodDelete MethodConnect = http.MethodConnect MethodOptions = http.MethodOptions MethodTrace = http.MethodTrace )
const ( StatusContinue = http.StatusContinue StatusSwitchingProtocols = http.StatusSwitchingProtocols StatusProcessing = http.StatusProcessing StatusEarlyHints = http.StatusEarlyHints StatusOK = http.StatusOK StatusCreated = http.StatusCreated StatusAccepted = http.StatusAccepted StatusNonAuthoritativeInfo = http.StatusNonAuthoritativeInfo StatusNoContent = http.StatusNoContent StatusResetContent = http.StatusResetContent StatusPartialContent = http.StatusPartialContent StatusMultiStatus = http.StatusMultiStatus StatusAlreadyReported = http.StatusAlreadyReported StatusIMUsed = http.StatusIMUsed StatusMultipleChoices = http.StatusMultipleChoices StatusMovedPermanently = http.StatusMovedPermanently StatusFound = http.StatusFound StatusSeeOther = http.StatusSeeOther StatusNotModified = http.StatusNotModified StatusUseProxy = http.StatusUseProxy StatusTemporaryRedirect = http.StatusTemporaryRedirect StatusPermanentRedirect = http.StatusPermanentRedirect StatusBadRequest = http.StatusBadRequest StatusPaymentRequired = http.StatusPaymentRequired StatusForbidden = http.StatusForbidden StatusNotFound = http.StatusNotFound StatusMethodNotAllowed = http.StatusMethodNotAllowed StatusNotAcceptable = http.StatusNotAcceptable StatusProxyAuthRequired = http.StatusProxyAuthRequired StatusRequestTimeout = http.StatusRequestTimeout StatusConflict = http.StatusConflict StatusGone = http.StatusGone StatusLengthRequired = http.StatusLengthRequired StatusPreconditionFailed = http.StatusPreconditionFailed StatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge StatusRequestURITooLong = http.StatusRequestURITooLong StatusUnsupportedMediaType = http.StatusUnsupportedMediaType StatusRequestedRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable StatusExpectationFailed = http.StatusExpectationFailed StatusTeapot = http.StatusTeapot StatusMisdirectedRequest = http.StatusMisdirectedRequest StatusUnprocessableEntity = http.StatusUnprocessableEntity StatusLocked = http.StatusLocked StatusFailedDependency = http.StatusFailedDependency StatusTooEarly = http.StatusTooEarly StatusUpgradeRequired = http.StatusUpgradeRequired StatusPreconditionRequired = http.StatusPreconditionRequired StatusTooManyRequests = http.StatusTooManyRequests StatusRequestHeaderFieldsTooLarge = http.StatusRequestHeaderFieldsTooLarge StatusInternalServerError = http.StatusInternalServerError StatusNotImplemented = http.StatusNotImplemented StatusBadGateway = http.StatusBadGateway StatusGatewayTimeout = http.StatusGatewayTimeout StatusHTTPVersionNotSupported = http.StatusHTTPVersionNotSupported StatusVariantAlsoNegotiates = http.StatusVariantAlsoNegotiates StatusInsufficientStorage = http.StatusInsufficientStorage StatusLoopDetected = http.StatusLoopDetected StatusNotExtended = http.StatusNotExtended StatusNetworkAuthenticationRequired = http.StatusNetworkAuthenticationRequired )
const ( DefaultMaxHeaderBytes = http.DefaultMaxHeaderBytes DefaultMaxIdleConnsPerHost = http.DefaultMaxIdleConnsPerHost TimeFormat = http.TimeFormat TrailerPrefix = http.TrailerPrefix )
Variables ¶
var ( ErrNotSupported = http.ErrNotSupported ErrUnexpectedTrailer = http.ErrUnexpectedTrailer // Deprecated ErrMissingBoundary = http.ErrMissingBoundary ErrNotMultipart = http.ErrNotMultipart ErrHeaderTooLong = http.ErrHeaderTooLong // Deprecated ErrShortBody = http.ErrShortBody // Deprecated ErrMissingContentLength = http.ErrMissingContentLength // Deprecated ErrBodyNotAllowed = http.ErrBodyNotAllowed ErrHijacked = http.ErrHijacked ErrContentLength = http.ErrContentLength ErrWriteAfterFlush = http.ErrWriteAfterFlush // Deprecated ServerContextKey = http.ServerContextKey LocalAddrContextKey = http.LocalAddrContextKey DefaultClient = http.DefaultClient DefaultServeMux = http.DefaultServeMux ErrAbortHandler = http.ErrAbortHandler ErrBodyReadAfterClose = http.ErrBodyReadAfterClose ErrHandlerTimeout = http.ErrHandlerTimeout ErrLineTooLong = http.ErrLineTooLong ErrMissingFile = http.ErrMissingFile ErrNoCookie = http.ErrNoCookie ErrNoLocation = http.ErrNoLocation ErrSchemeMismatch = http.ErrSchemeMismatch ErrServerClosed = http.ErrServerClosed ErrSkipAltProtocol = http.ErrSkipAltProtocol ErrUseLastResponse = http.ErrUseLastResponse NoBody = http.NoBody )
var WithJar = WithCookieJar
WithJar is just an alias to WithCookieJar
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
CloseIdleConnections()
Do(*http.Request) (ClientResponse, error)
Get(string) (ClientResponse, error)
Head(string) (ClientResponse, error)
Post(string, string, io.Reader) (ClientResponse, error)
PostForm(string, url.Values) (ClientResponse, error)
}
Client is an interface for the net/http.Client struct
func NewClient ¶
func NewClient(options ...ClientOption) Client
NewClient creates a Client with default values
type ClientOption ¶
ClientOption allows you to set options on a client in the NewClient constructor
func WithCheckRedirect ¶
Set the net/http.Client CheckRedirect
func WithTransport ¶
func WithTransport(t RoundTripper) ClientOption
Set the net/http.Client Transport
type ClientRequest ¶
ClientRequest provides an interface to a net/http.Request for use on a client making an http request.
func NewClientRequest ¶
func NewClientRequest(method, url string, body io.Reader, options ...ClientRequestOption) (ClientRequest, error)
func NewClientRequestWithContext ¶
func NewClientRequestWithContext(ctx context.Context, method, url string, body io.Reader, options ...ClientRequestOption) (ClientRequest, error)
func ReadRequest ¶
func ReadRequest(r *bufio.Reader) (ClientRequest, error)
ReadRequest is a "constructor" that constructs a Request from a Reader
type ClientRequestOption ¶
ClientRequestOption allows you to set options on a request in the NewClientRequest constructor
func WithContentLength ¶
func WithContentLength(l int64) ClientRequestOption
Set the net/http.Request ContentLength
func WithGetBody ¶
func WithGetBody(f func() (io.ReadCloser, error)) ClientRequestOption
Set the net/http.Request GetBody
func WithHeader ¶
func WithHeader(name string, values ...string) ClientRequestOption
Set a an individual net/http.Request Header
func WithHeaders ¶
func WithHeaders(headers Header) ClientRequestOption
Set the net/http.Request Header map
func WithMultipartForm ¶
func WithMultipartForm(form *multipart.Form) ClientRequestOption
Set the net/http.Request MultipartForm
func WithPostForm ¶
func WithPostForm(form url.Values) ClientRequestOption
Set the net/http.Request PostForm
func WithRemoteAddr ¶
func WithRemoteAddr(addr string) ClientRequestOption
Set the net/http.RequestForm RemoteAddr
func WithRequestURI ¶
func WithRequestURI(uri string) ClientRequestOption
Set the net/http.RequestForm RequestURI
func WithTrailer ¶
func WithTrailer(t Header) ClientRequestOption
Set the net/http.RequestForm Trailer
func WithTransferEncoding ¶
func WithTransferEncoding(encodings []string) ClientRequestOption
Set the net/http.Request TransferEncoding
type ClientResponse ¶
type ClientResponse interface {
// Simple pass-through methods:
Cookies() []*Cookie
Location() (*url.URL, error)
ProtoAtLeast(int, int) bool
Write(io.Writer) error
// Methods allowing access to member variables:
Status() string
StatusCode() int
Proto() string
ProtoMajor() int
ProtoMinor() int
Header() Header
Body() io.ReadCloser
ContentLength() int64
TransferEncoding() []string
Close() bool
Uncompressed() bool
Trailer() Header
Request() ClientRequest
TLS() *tls.ConnectionState
}
ClientResponse is an interface to a Response received by the client.
type FileSystem ¶
type FileSystem = http.FileSystem
type HTTP ¶
type HTTP interface {
// ClientResponse constructors:
Get(string) (ClientResponse, error)
Head(string) (ClientResponse, error)
Post(string, string, io.Reader) (ClientResponse, error)
PostForm(string, url.Values) (ClientResponse, error)
ReadResponse(*bufio.Reader, *http.Request) (ClientResponse, error)
CanonicalHeaderKey(string) string
DetectContentType([]byte) string
Error(ResponseWriter, string, int)
Handle(string, http.Handler)
HandleFunc(string, func(ResponseWriter, *http.Request))
ListenAndServe(string, http.Handler) error
ListenAndServeTLS(string, string, string, http.Handler) error
MaxBytesReader(ResponseWriter, io.ReadCloser, int64) io.ReadCloser
NotFound(ResponseWriter, *http.Request)
ParseHTTPVersion(string) (int, int, bool)
ParseTime(string) (time.Time, error)
ProxyFromEnvironment(*http.Request) (*url.URL, error)
ProxyURL(*url.URL) func(*http.Request) (*url.URL, error)
Redirect(ResponseWriter, *http.Request, string, int)
Serve(net.Listener, http.Handler) error
ServeContent(ResponseWriter, *http.Request, string, time.Time, io.ReadSeeker)
ServeFile(ResponseWriter, *http.Request, string)
ServeFileFS(ResponseWriter, *http.Request, fs.FS, string)
ServeTLS(net.Listener, http.Handler, string, string) error
SetCookie(ResponseWriter, *Cookie)
StatusText(int) string
}
HTTP is an interface for the functions in the net/http package
type Handler ¶
HTTP2Config is being added in 1.24.0. When it's a little more baked, I'll add it here: type HTTP2Config = http.HTTP2Config
type HandlerFunc ¶
type HandlerFunc = http.HandlerFunc
type MaxBytesError ¶
type MaxBytesError = http.MaxBytesError
type PushOptions ¶
type PushOptions = http.PushOptions
Protocols is being added in 1.24.0. When it's a little more baked, I'll add it here: type Protocols = http.Protocols
type ResponseWriter ¶
type ResponseWriter = http.ResponseWriter
type RoundTripper ¶
type RoundTripper = http.RoundTripper
type Server ¶
type Server interface {
Close() error
ListenAndServe() error
ListenAndServeTLS(string, string) error
RegisterOnShutdown(func())
Serve(net.Listener) error
ServeTLS(net.Listener, string, string) error
SetKeepAlivesEnabled(bool)
Shutdown(context.Context) error
}
Server is an interface for the net/http.Server struct
func NewServer ¶
func NewServer(options ...ServerOption) Server
NewServer creates a Server with default values
type ServerOption ¶
ServerOption allows you to set options on a server in the NewServer constructor
func WithBaseContext ¶
func WithBaseContext(f func(net.Listener) context.Context) ServerOption
Set the net/http.Server BaseContext
func WithConnContext ¶
Set the net/http.Server ConnContext
func WithConnState ¶
func WithConnState(f func(net.Conn, ConnState)) ServerOption
Set the net/http.Server ConnState Note that the function will be called with the underlying connection, not an interface.
func WithDisableGeneralOptionsHandler ¶
func WithDisableGeneralOptionsHandler(v bool) ServerOption
Set the net/http.Server DisableGeneralOptionsHandler
func WithIdleTimeout ¶
func WithIdleTimeout(t time.Duration) ServerOption
Set the net/http.Server IdleTimeout
func WithMaxHeaderBytes ¶
func WithMaxHeaderBytes(n int) ServerOption
Set the net/http.Server MaxHeaderBytes
func WithReadHeaderTimeout ¶
func WithReadHeaderTimeout(t time.Duration) ServerOption
Set the net/http.Server ReadHeaderTimeout
func WithReadTimeout ¶
func WithReadTimeout(t time.Duration) ServerOption
Set the net/http.Server ReadTimeout
func WithTLSConfig ¶
func WithTLSConfig(cfg *tls.Config) ServerOption
Set the net/http.Server TLSConfig
func WithTLSNextProto ¶
Set the net/http.Server TLSNextProto TODO: Explore the possibility of replacing the function parameters with interfaces
func WithWriteTimeout ¶
func WithWriteTimeout(t time.Duration) ServerOption
Set the net/http.Server WriteTimeout
type ServerRequest ¶
type ServerRequest interface {
Method() string
URL() *url.URL
Proto() string
ProtoMajor() int
ProtoMinor() int
Header() Header
Body() io.ReadCloser
GetBody() func() (io.ReadCloser, error)
ContentLength() int64
TransferEncoding() []string
Host() string
Form() url.Values
PostForm() url.Values
MultipartForm() *multipart.Form
Trailer() Header
RemoteAddr() string
RequestURI() string
TLS() *tls.ConnectionState
Pattern() string
}
ServerRequest provides an interface to a net/http.Request for use on a server receiving an http request.