ghttp

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapperHandler

func WrapperHandler(handlerFunc HandlerFunc) http.HandlerFunc

Types

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    string                 `json:"error_code"`
	ErrorMessage string                 `json:"error_message"`
	ErrorParams  map[string]interface{} `json:"error_params"`
	// contains filtered or unexported fields
}

ErrorResponse container status code and error code message, it will encode to a json string and add to http body

func NewErrorRes

func NewErrorRes(statusCode int) *ErrorResponse

NewErrorRes creates a instance of ErrorResponse

func (*ErrorResponse) Error

func (er *ErrorResponse) Error() string

Error implements error interface

func (*ErrorResponse) WithMsg

func (er *ErrorResponse) WithMsg(errMsg string) *ErrorResponse

WithMsg add error message

func (*ErrorResponse) WithParam

func (er *ErrorResponse) WithParam(key string, value interface{}) *ErrorResponse

WithParam add error parameters with key and value

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request) error

HandlerFunc is http handler function return error

Jump to

Keyboard shortcuts

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