handler

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dep

type Dep struct {
	Log log.LoggerInterface
}

type EndpointHandler

type EndpointHandler func(http.ResponseWriter, *http.Request) ResponseInterface

EndpointHandler ...

func (EndpointHandler) ServeHTTP

func (fn EndpointHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ErrorResponseParam

type ErrorResponseParam struct {
	Status  int
	Err     error
	ErrCode int
	Message string
	Data    map[string]interface{}
}

type HTTPResponse

type HTTPResponse struct {
	Logger log.LoggerInterface
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(dep Dep) *HTTPResponse

func (HTTPResponse) GetContentType added in v1.1.0

func (res HTTPResponse) GetContentType() string

func (HTTPResponse) GetData

func (res HTTPResponse) GetData() interface{}

GetData ...

func (HTTPResponse) GetErrCode

func (res HTTPResponse) GetErrCode() int

GetErrCode ...

func (HTTPResponse) GetError

func (res HTTPResponse) GetError() error

GetError ...

func (HTTPResponse) GetErrorMessage

func (res HTTPResponse) GetErrorMessage() string

GetErrorMessage get error message from message or error object

func (HTTPResponse) GetErrorMessageVerbose

func (res HTTPResponse) GetErrorMessageVerbose() string

GetErrorMessageVerbose get full string with error code, message and error object

func (HTTPResponse) GetStatus

func (res HTTPResponse) GetStatus() int

GetStatus ...

func (HTTPResponse) HasError

func (res HTTPResponse) HasError() bool

HasError ...

func (HTTPResponse) HasNoContent

func (res HTTPResponse) HasNoContent() bool

HasNoContent ...

func (HTTPResponse) SetError

func (res HTTPResponse) SetError(err error, errCode int, message string) HTTPResponse

SetError ...

func (HTTPResponse) SetErrorWithData

func (res HTTPResponse) SetErrorWithData(errParam ErrorResponseParam, data interface{}) HTTPResponse

func (HTTPResponse) SetErrorWithStatus

func (res HTTPResponse) SetErrorWithStatus(status int, err error, errCode int, message string) HTTPResponse

SetErrorWithStatus ...

func (HTTPResponse) SetOk

func (res HTTPResponse) SetOk(data interface{}) HTTPResponse

SetOk ...

func (HTTPResponse) SetOkWithStatus

func (res HTTPResponse) SetOkWithStatus(status int, data interface{}) HTTPResponse

SetOkWithStatus ...

func (HTTPResponse) SetOkWithText added in v1.1.0

func (res HTTPResponse) SetOkWithText(contentType string, data string) HTTPResponse

type ResponseInterface

type ResponseInterface interface {
	SetOk(data interface{}) HTTPResponse
	SetOkWithStatus(status int, data interface{}) HTTPResponse
	SetOkWithText(contentType string, data string) HTTPResponse
	SetError(err error, errCode int, message string) HTTPResponse
	SetErrorWithStatus(status int, err error, errCode int, message string) HTTPResponse
	SetErrorWithData(errParam ErrorResponseParam, data interface{}) HTTPResponse
	HasError() bool
	GetData() interface{}
	GetError() error
	GetStatus() int
	GetErrCode() int
	GetErrorMessage() string
	GetErrorMessageVerbose() string
	HasNoContent() bool
	GetContentType() string
}

Jump to

Keyboard shortcuts

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