sdkhttp

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadySent     = sdk.Errorf("brock/sdkhttp: already sent to the client")
	ErrAlreadyStreamed = sdk.Errorf("brock/sdkhttp: already streamed to the client")
	ErrUnimplemented   = sdk.Errorf("brock/sdkhttp: unimplemented")
)
View Source
var Body body
View Source
var Header header
View Source
var MultipartForm multipartForm
View Source
var Query query
View Source
var Request request
View Source
var Wrap wrap

Functions

func Mux

func Mux() *mux

func NamedArgsFromRequest

func NamedArgsFromRequest(r *http.Request) url.Values

NamedArgsFromRequest is a helper function that extract url.Values that have been parsed using MuxMatcherPattern, url.Values should not be empty if parsing is successful and should be able to extract further following url.Values, same keys in the pattern result in new value added in url.Values.

func PanicRecoveryFromRequest

func PanicRecoveryFromRequest(r *http.Request) any

PanicRecoveryFromRequest is a helper function that extract error value when panic occurred, the value is saved to *http.Request after recovery process and right before calling mux.PanicHandler.

Types

type WrapHandler

type WrapHandler interface {
	// Err get any error passed from the previous handler
	Err() error
	// Next pass the error to the next handler
	Next(err error)
	// Send is a shorthand for set the statusCode, header & body
	Send(statusCode int, header http.Header, body io.Reader) (int, error)
	// Stream is used for streaming response to the client
	Stream(p []byte) (int, error)
	// H2Push initiate a HTTP/2 server push
	H2Push(target, method string, header http.Header) error
}

WrapHandler helper contract.

Jump to

Keyboard shortcuts

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