kitDefaults

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 3 Imported by: 2

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

type DecodeRequestFunc func(context.Context, *http.Request) (request interface{}, err error)

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.

type HttpCoder

type HttpCoder interface {
	StatusCode() int
}

HttpCoder is any response that returns a status code

Jump to

Keyboard shortcuts

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