wrapper

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomHTTPErrorHandler

func CustomHTTPErrorHandler(err error, c echo.Context)

CustomHTTPErrorHandler custom echo http error

Types

type HTTPResponse

type HTTPResponse struct {
	Success bool        `json:"success"`
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Meta    interface{} `json:"meta,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Errors  interface{} `json:"errors,omitempty"`
}

HTTPResponse format

func NewHTTPResponse

func NewHTTPResponse(code int, message string, params ...interface{}) *HTTPResponse

NewHTTPResponse for create common response

func (*HTTPResponse) JSON

func (resp *HTTPResponse) JSON(w http.ResponseWriter) error

JSON for set http JSON response (Content-Type: application/json) with parameter is http response writer

func (*HTTPResponse) XML

func (resp *HTTPResponse) XML(w http.ResponseWriter) error

XML for set http XML response (Content-Type: application/xml)

type WrapResponseWriter

type WrapResponseWriter struct {
	StatusCode int
	http.ResponseWriter
}

func NewWrapResponseWriter

func NewWrapResponseWriter(res http.ResponseWriter) *WrapResponseWriter

func (WrapResponseWriter) Header

func (w WrapResponseWriter) Header() http.Header

Satisfy the http.ResponseWriter interface

func (WrapResponseWriter) Status

func (w WrapResponseWriter) Status() int

Give a way to get the status

func (WrapResponseWriter) Write

func (w WrapResponseWriter) Write(data []byte) (int, error)

func (WrapResponseWriter) WriteHeader

func (w WrapResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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