wrapper

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 default candi http response 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 WrapHTTPResponseWriter

type WrapHTTPResponseWriter struct {
	io.Writer
	http.ResponseWriter
	// contains filtered or unexported fields
}

WrapHTTPResponseWriter wrapper

func NewWrapHTTPResponseWriter

func NewWrapHTTPResponseWriter(w io.Writer, httpResponseWriter http.ResponseWriter) *WrapHTTPResponseWriter

NewWrapHTTPResponseWriter init new wrapper for http response writter

func (*WrapHTTPResponseWriter) Header

func (w *WrapHTTPResponseWriter) Header() http.Header

Header Satisfy the http.ResponseWriter interface

func (*WrapHTTPResponseWriter) StatusCode

func (w *WrapHTTPResponseWriter) StatusCode() int

StatusCode give a way to get the Code

func (*WrapHTTPResponseWriter) Write

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

func (*WrapHTTPResponseWriter) WriteHeader

func (w *WrapHTTPResponseWriter) WriteHeader(statusCode int)

WriteHeader method

Jump to

Keyboard shortcuts

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