gokit

package
v0.0.0-...-fb315dc Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeFromBase64

func DecodeFromBase64(ctx context.Context, r *http.Request) (interface{}, error)

func DecodeResponse

func DecodeResponse(_ context.Context, r *http.Response) (interface{}, error)

DecodeResponse will check the response for an error, and if there is, it will set the body to the error message

func DecodeString

func DecodeString(ctx context.Context, r *http.Request) (interface{}, error)

DecodeString will return the the body of the http request as a string

func EncodeError

func EncodeError(c context.Context, err error, w http.ResponseWriter)

EncodeError response back to the client

func EncodeErrorRequest

func EncodeErrorRequest(_ context.Context, r *http.Request, request interface{}) error

EncodeErrorRequest will extract the string message from the request error and add it to the body

func EncodeJsonRequest

func EncodeJsonRequest(_ context.Context, r *http.Request, request interface{}) error

EncodeJsonRequest will attempt to conver the input request

func EncodeRequest

func EncodeRequest(_ context.Context, r *http.Request, request interface{}) error

EncodeRequest converts the input request into a json string and adds it to the request body

func EncodeResponse

func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error

EncodeResponse Convert the response into the response body

func EncodeToBase64

func EncodeToBase64(_ context.Context, r *http.Request, request interface{}) error

EncodeToBase64 takes the byte array request and converts it to base64 before adding it to the request body

func GetChatId

func GetChatId(ctx context.Context) uint32

func GetJWTKeys

func GetJWTKeys() jwt.Keyfunc

func GetServerOpts

func GetServerOpts(logger kitlog.Logger, service machineLearning.Service) []kithttp.ServerOption

GetServerOpts creates a default server option with an error logger, error encoder and a http request logger.

Types

type ErrorResponse

type ErrorResponse struct {
	// error message
	//
	// required: true
	Error string `json:"error"`
}

User represents a generic error

swagger:model errorResponse

Jump to

Keyboard shortcuts

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