commonhttp

package
v1.0.0-beta.100 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyResponseEncoder

func EmptyResponseEncoder[Response any](statusCode int) httptransport.ResponseEncoder[Response]

func ErrorEncoder

func ErrorEncoder(ctx context.Context, _ error, w http.ResponseWriter) bool

ErrorEncoder encodes an error as HTTP 500 Internal Server Error.

func JSONRequestBodyDecoder

func JSONRequestBodyDecoder(r *http.Request, out any) error

func JSONResponseEncoder

func JSONResponseEncoder[Response any](_ context.Context, w http.ResponseWriter, response Response) error

JSONResponseEncoder encodes a response as JSON.

func JSONResponseEncoderWithStatus

func JSONResponseEncoderWithStatus[Response any](statusCode int) httptransport.ResponseEncoder[Response]

Types

type ErrorWithHTTPStatusCode

type ErrorWithHTTPStatusCode struct {
	StatusCode int
	Extensions []ExtendProblemFunc
	// contains filtered or unexported fields
}

func NewHTTPError

func NewHTTPError(statusCode int, err error, extensions ...ExtendProblemFunc) ErrorWithHTTPStatusCode

func (ErrorWithHTTPStatusCode) EncodeError

type ExtendProblemFunc

type ExtendProblemFunc func() (name string, details string)

func ExtendProblem

func ExtendProblem(name, details string) ExtendProblemFunc

Jump to

Keyboard shortcuts

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