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 HTTPMiddlewareTracer(cfg HTTPMiddlewareTracerConfig) func(http.Handler) http.Handler
 - type HTTPMiddlewareTracerConfig
 - type HTTPResponse
 - type WrapHTTPResponseWriter
 
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 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(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