Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHttpErrorEncoder ¶
func DefaultHttpErrorEncoder(_ context.Context, err error, w http.ResponseWriter)
DefaultHttpErrorEncoder
Computes the default http error response. When implementing custom gkBoot.HttpEncoder, ensure to implement your own error encoder handler.
func DefaultHttpResponseEncoder ¶
func DefaultHttpResponseEncoder(ctx context.Context, w http.ResponseWriter, response interface{}) error
DefaultHttpResponseEncoder
Computes the http response encoding, for different formats, you must attach your own gkBoot.HttpEncoder to your gkBoot.Service for each one defined
Types ¶
type CodedError ¶
type CodedError interface {
StatusCode() int
}
CodedError
Indicates an error capable of storing a status code. Used with default (en/de)-coders
type DecodeRequestFunc ¶
DecodeRequestFunc any decoder that takes on this format, goal is to translate http.Request to API request object
type EncodeResponseFunc ¶
type EncodeResponseFunc func(context.Context, http.ResponseWriter, interface{}) error
EncodeResponseFunc any encoder that takes on this format, goal is to translate API response object to the http.ResponseWriter
type Failer ¶
type Failer interface {
Failed() error
}
Failer may be implemented by Go kit response types that contain business logic error details. If Failed returns a non-nil error, the Go kit transport layer may interpret this as a business logic error, and may encode it differently than a regular, successful response.
It's not necessary for your response types to implement Failer, but it may help for more sophisticated use cases. The addsvc example shows how Failer should be used by a complete application.