Documentation ¶
Index ¶
- func HTTPHandlerDefaultRoot(w http.ResponseWriter, r *http.Request)
- func HTTPHandlerMemstats(w http.ResponseWriter, r *http.Request)
- type HTTPResponse
- type WrapHTTPResponseWriter
- func (w *WrapHTTPResponseWriter) GetContent() []byte
- func (w *WrapHTTPResponseWriter) GetContentLength() int
- func (w *WrapHTTPResponseWriter) Header() http.Header
- func (w *WrapHTTPResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *WrapHTTPResponseWriter) SetMaxWriteSize(max int)
- func (w *WrapHTTPResponseWriter) StatusCode() int
- func (w *WrapHTTPResponseWriter) Write(data []byte) (int, error)
- func (w *WrapHTTPResponseWriter) WriteHeader(statusCode int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandlerDefaultRoot ¶ added in v1.14.3
func HTTPHandlerDefaultRoot(w http.ResponseWriter, r *http.Request)
HTTPHandlerDefaultRoot default root http handler
func HTTPHandlerMemstats ¶ added in v1.14.3
func HTTPHandlerMemstats(w http.ResponseWriter, r *http.Request)
HTTPHandlerMemstats calculate runtime statistic
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 NewHTTPResponseWithMeta ¶ added in v1.17.2
func NewHTTPResponseWithMeta[M any](code int, message string, meta M, params ...any) *HTTPResponse
NewHTTPResponse for create common response with meta
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 { http.ResponseWriter // contains filtered or unexported fields }
WrapHTTPResponseWriter wrapper
func NewWrapHTTPResponseWriter ¶
func NewWrapHTTPResponseWriter(responseBuff *bytes.Buffer, httpResponseWriter http.ResponseWriter) *WrapHTTPResponseWriter
NewWrapHTTPResponseWriter init new wrapper for http response writter
func (*WrapHTTPResponseWriter) GetContent ¶ added in v1.14.11
func (w *WrapHTTPResponseWriter) GetContent() []byte
GetContent get response content
func (*WrapHTTPResponseWriter) GetContentLength ¶ added in v1.14.11
func (w *WrapHTTPResponseWriter) GetContentLength() int
GetContentLength get response content length
func (*WrapHTTPResponseWriter) Header ¶
func (w *WrapHTTPResponseWriter) Header() http.Header
Header Satisfy the http.ResponseWriter interface
func (*WrapHTTPResponseWriter) Hijack ¶ added in v1.17.15
func (w *WrapHTTPResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack method
func (*WrapHTTPResponseWriter) SetMaxWriteSize ¶ added in v1.14.11
func (w *WrapHTTPResponseWriter) SetMaxWriteSize(max int)
SetMaxWriteSize set max write size to buffer
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