response

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// response flag
	SUCCESS = responseutil.SUCCESS
	FAILURE = responseutil.FAILURE
	UNKNOWN = responseutil.UNKNOWN
)
View Source
const (
	CONTENT_TYPE_JSON string = "application/json; charset=utf-8"
	CONTENT_TYPE_TEXT string = "text/plain; charset=utf-8"
)
View Source
const (
	Json = JsonFormatter("")
	Text = TextFormatter("")
)

Variables

This section is empty.

Functions

func Failure

func Failure(ctx *http.RequestCtx, contentType string, message []byte, statusCode int)

func SendFailure

func SendFailure(ctx *http.RequestCtx, resp *http.Response)

func SendSuccess

func SendSuccess(ctx *http.RequestCtx, resp *http.Response)

func Success

func Success(ctx *http.RequestCtx, contentType string, body []byte)

Types

type ContentFormatter

type ContentFormatter interface {
	Success(ctx *http.RequestCtx, body interface{}) error
	Failure(ctx *http.RequestCtx, body interface{}, statusCode int) error
}

type Error

type Error struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(msg string) *Error

func WrapError

func WrapError(err error, msg string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type JsonFormatter

type JsonFormatter string

func (JsonFormatter) Failure

func (f JsonFormatter) Failure(ctx *http.RequestCtx, body interface{}, statusCode int) error

func (JsonFormatter) Success

func (f JsonFormatter) Success(ctx *http.RequestCtx, body interface{}) error

type ResponseFlag

type ResponseFlag = responseutil.ResponseFlag

type ResponseState

type ResponseState = responseutil.ResponseState

func ExtractResponseState

func ExtractResponseState(ctx *http.RequestCtx) ResponseState

type TextFormatter

type TextFormatter string

func (TextFormatter) Failure

func (f TextFormatter) Failure(ctx *http.RequestCtx, body interface{}, statusCode int) error

func (TextFormatter) Success

func (f TextFormatter) Success(ctx *http.RequestCtx, body interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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