Documentation
¶
Index ¶
- func HTTPHandlerDefaultRoot(w http.ResponseWriter, r *http.Request)
- func HTTPHandlerMemstats(w http.ResponseWriter, r *http.Request)
- func HTTPMiddlewareCORS(allowMethods, allowHeaders, allowOrigins []string, exposeHeaders []string, ...) func(http.Handler) http.Handler
- func HTTPMiddlewareLog(isActive bool, writer io.Writer) func(http.Handler) http.Handler
- func HTTPMiddlewareTracer(cfg HTTPMiddlewareTracerConfig) func(http.Handler) http.Handler
- type HTTPMiddlewareTracerConfig
- type HTTPResponse
- type WrapHTTPResponseWriter
- func (w *WrapHTTPResponseWriter) GetContent() []byte
- func (w *WrapHTTPResponseWriter) GetContentLength() int
- func (w *WrapHTTPResponseWriter) Header() http.Header
- 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
func HTTPMiddlewareCORS ¶ added in v1.14.0
func HTTPMiddlewareCORS( allowMethods, allowHeaders, allowOrigins []string, exposeHeaders []string, allowCredential bool, ) func(http.Handler) http.Handler
HTTPMiddlewareCORS middleware wrapper for cors
func HTTPMiddlewareLog ¶ added in v1.15.0
HTTPMiddlewareLog middleware
func HTTPMiddlewareTracer ¶ added in v1.14.0
func HTTPMiddlewareTracer(cfg HTTPMiddlewareTracerConfig) func(http.Handler) http.Handler
HTTPMiddlewareTracer middleware wrapper for tracer
Types ¶
type HTTPMiddlewareTracerConfig ¶ added in v1.14.3
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 {
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) 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