grpchttpendpoint

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecodeRequest = errors.New("cannot decode request")

ErrDecodeRequest indicate an error occur on decoding the request.

View Source
var ErrEmptyRequestBody = errors.New("empty request body")

ErrEmptyRequestBody indicate the request body is empty.

Functions

func DecodeJSONRequest

func DecodeJSONRequest(w http.ResponseWriter, r *http.Request, m proto.Message, opts *protojson.UnmarshalOptions) error

DecodeJSONRequest decodes the JSON request into the given proto message reference. The HTTP error status code will be respond if decoding failed. UnmarshalOptions opts cannot be nil.

func ErrorStatusResponse

func ErrorStatusResponse(w http.ResponseWriter, err error)

ErrorStatusResponse generate HTTP error response based on given error.

func JSONResponseWithStatusCode

func JSONResponseWithStatusCode(w http.ResponseWriter, m proto.Message, statusCode int, opts *protojson.MarshalOptions) (err error)

JSONResponseWithStatusCode generate JSON response based on given protobuf message m with given statusCode and private Cache-Control headers enabled. MarshalOptions opts cannot be nil.

func RequestPathInBytes

func RequestPathInBytes(r *http.Request) []byte

RequestPathInBytes returns the URL path of request in bytes. Leading slashes will be removed.

Types

type ErrLoadRequest

type ErrLoadRequest struct {
	Err error
}

ErrLoadRequest indicate having issue on loading the request.

func (ErrLoadRequest) Error

func (e ErrLoadRequest) Error() string

func (ErrLoadRequest) Unwrap

func (e ErrLoadRequest) Unwrap() []error

type ErrMalformedRequest

type ErrMalformedRequest struct {
	Err error
}

ErrMalformedRequest indicate the request is malformed and cannot be decode.

func (ErrMalformedRequest) Error

func (e ErrMalformedRequest) Error() string

func (ErrMalformedRequest) Unwrap

func (e ErrMalformedRequest) Unwrap() []error

Jump to

Keyboard shortcuts

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