Documentation
¶
Index ¶
- func ClientIP(r *http.Request) string
- func DebugPprofBlockHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofCmdlineHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofGoroutineHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofHeapHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofMutexHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofProfileHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofSymbolHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofThreadcreateHandler(w http.ResponseWriter, r *http.Request)
- func DebugPprofTraceHandler(w http.ResponseWriter, r *http.Request)
- func Error(w http.ResponseWriter, error string, code int)
- func ErrorRender(w http.ResponseWriter, code int, err error)
- func GCHandler(w http.ResponseWriter, _ *http.Request)
- func GetLocalIP() (string, error)
- func GetPrivateIP() net.IP
- func GetPrivateIPByName(name string) net.IP
- func GetReqBody(r *http.Request) ([]byte, error)
- func GetUrlQuery(r *http.Request) map[string]string
- func JSONRender(w http.ResponseWriter, data interface{})
- func LimitHandle(w http.ResponseWriter, r *http.Request)
- func NewQuery() *query
- func PingPong(w http.ResponseWriter, _ *http.Request)
- func SetMode(mode RouterMode)
- func StartPprofService(addr string) (*http.ServeMux, error)
- type Handle
- type HandleContinued
- type HttpReply
- type Response
- func (this *Response) SendJson(data interface{})
- func (this *Response) SendJsonBytes(bytes []byte)
- func (this *Response) SendJsonHttpReplyError(err error)
- func (this *Response) SendJsonHttpReplySuccess(data interface{})
- func (this *Response) SendText(text string)
- func (this *Response) SetAllowMethod(method string) *Response
- func (this *Response) SetHttpStatus(httpStatus int) *Response
- type ResponseWriter
- type RouterMode
- type Server
- func (s *Server) CatchPanicAndSendErrReply(w http.ResponseWriter)
- func (s *Server) Close()
- func (s *Server) Handle(method string, path string, handle Handle)
- func (s *Server) Handles(method string, path string, handles []HandleContinued)
- func (s *Server) HandlesMethods(methods []string, path string, handles []HandleContinued, end HandleContinued)
- func (s *Server) Name() string
- func (s *Server) Run() error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown()
- type ServerConfig
- type UriParams
- type UriParamsMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugPprofBlockHandler ¶
func DebugPprofBlockHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofCmdlineHandler ¶
func DebugPprofCmdlineHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofGoroutineHandler ¶
func DebugPprofGoroutineHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofHandler ¶
func DebugPprofHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofHeapHandler ¶
func DebugPprofHeapHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofMutexHandler ¶
func DebugPprofMutexHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofProfileHandler ¶
func DebugPprofProfileHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofSymbolHandler ¶
func DebugPprofSymbolHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofThreadcreateHandler ¶
func DebugPprofThreadcreateHandler(w http.ResponseWriter, r *http.Request)
func DebugPprofTraceHandler ¶
func DebugPprofTraceHandler(w http.ResponseWriter, r *http.Request)
func Error ¶
func Error(w http.ResponseWriter, error string, code int)
Error replies to the request with the specified error message and HTTP code. It does not otherwise end the request; the caller should ensure no further writes are done to w. The error message should be plain text.
func ErrorRender ¶
func ErrorRender(w http.ResponseWriter, code int, err error)
ErrorRender replies to the request with the specified error message and 500 code.
func GetLocalIP ¶
func GetPrivateIP ¶
GetPrivateIP returns a private IP address, or panics if no IP is available.
func GetPrivateIPByName ¶
func JSONRender ¶
func JSONRender(w http.ResponseWriter, data interface{})
JSONRender serializes the given struct as JSON into the response body.
func LimitHandle ¶
func LimitHandle(w http.ResponseWriter, r *http.Request)
func SetMode ¶
func SetMode(mode RouterMode)
Types ¶
type HandleContinued ¶
type HttpReply ¶
type HttpReply struct { Code int64 `json:"code"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` }
http protocal
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(respWriter http.ResponseWriter) *Response
func (*Response) SendJsonBytes ¶
func (*Response) SendJsonHttpReplyError ¶
func (*Response) SendJsonHttpReplySuccess ¶
func (this *Response) SendJsonHttpReplySuccess(data interface{})
func (*Response) SetAllowMethod ¶
func (*Response) SetHttpStatus ¶
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter, writer io.Writer) *ResponseWriter
type RouterMode ¶
type RouterMode string
const ( RouterModeHttpRouter RouterMode = "httprouter" RouterModeGorilla RouterMode = "gorilla" StartTime = "__start_time" )
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a http server
func NewServer ¶
func NewServer(config *ServerConfig) *Server
NewUriServer creates the server with uri parsing
func (*Server) CatchPanicAndSendErrReply ¶
func (s *Server) CatchPanicAndSendErrReply(w http.ResponseWriter)
func (*Server) Handles ¶
func (s *Server) Handles(method string, path string, handles []HandleContinued)
process multiple handles
func (*Server) HandlesMethods ¶
func (s *Server) HandlesMethods(methods []string, path string, handles []HandleContinued, end HandleContinued)
type ServerConfig ¶
type UriParams ¶
func NewMockUriParams ¶
type UriParamsMap ¶
type UriParamsMap struct {
// contains filtered or unexported fields
}
func (*UriParamsMap) ByName ¶
func (p *UriParamsMap) ByName(name string) string
func (*UriParamsMap) Put ¶
func (p *UriParamsMap) Put(name, value string)
Click to show internal directories.
Click to hide internal directories.