Documentation ¶
Index ¶
- func PostLoggingFilter(_ http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
- func PreLoggingFilter(_ http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
- func ReqValidatorFilter(w http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
- type WebsocketHandler
- type XHTTPHandler
- func (h *XHTTPHandler) AddReqHandlers(handlers ...XHandler) *XHTTPHandler
- func (h *XHTTPHandler) AddRespHandlers(handlers ...XHandler) *XHTTPHandler
- func (h *XHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *XHTTPHandler) ServeXHTTP(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- type XHandler
- type XHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PostLoggingFilter ¶
func PostLoggingFilter(_ http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
PostLoggingFilter a log filter apply on crankerRouter's registerHandler's http request, not websocket request log after the request is handled by target handler
func PreLoggingFilter ¶
func PreLoggingFilter(_ http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
PreLoggingFilter 1. applied on crankerRouter's websocketServer's http request, not websocket request. 2. applied on crankerRouter's httpServer log before the request is handled by target handler
func ReqValidatorFilter ¶
func ReqValidatorFilter(w http.ResponseWriter, r *http.Request, _ httprouter.Params) bool
ReqValidatorFilter applied on router's httpServer, it aborts requests with invalid HTTPMethod
Types ¶
type WebsocketHandler ¶
type WebsocketHandler struct {
// contains filtered or unexported fields
}
func NewWebsocketHandler ¶
func NewWebsocketHandler() *WebsocketHandler
func NewWebsocketHandler2 ¶
func NewWebsocketHandler2(factory func(w http.ResponseWriter, r *http.Request) *router_socket.RouterSocket) *WebsocketHandler
func (*WebsocketHandler) Handle ¶
func (w *WebsocketHandler) Handle(respWriter http.ResponseWriter, req *http.Request, params httprouter.Params) bool
func (*WebsocketHandler) WithWebsocketFactory ¶
func (w *WebsocketHandler) WithWebsocketFactory(factory func(w http.ResponseWriter, r *http.Request) *router_socket.RouterSocket) *WebsocketHandler
type XHTTPHandler ¶
type XHTTPHandler struct {
// contains filtered or unexported fields
}
XHTTPHandler an implement of net/http Handler, to implement pipeline/filter pattern easily
func NewXHttpHandler ¶
func NewXHttpHandler(targetHandler XHandler) *XHTTPHandler
func (*XHTTPHandler) AddReqHandlers ¶
func (h *XHTTPHandler) AddReqHandlers(handlers ...XHandler) *XHTTPHandler
func (*XHTTPHandler) AddRespHandlers ¶
func (h *XHTTPHandler) AddRespHandlers(handlers ...XHandler) *XHTTPHandler
func (*XHTTPHandler) ServeHTTP ¶
func (h *XHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
To register on origin http ServeMux
func (*XHTTPHandler) ServeXHTTP ¶
func (h *XHTTPHandler) ServeXHTTP(w http.ResponseWriter, r *http.Request, params httprouter.Params)
ServeXHTTP To register handler on httprouter
type XHandler ¶
type XHandler interface { // Handle if this method return true, it prevents pending reqHandlers from being called Handle(w http.ResponseWriter, r *http.Request, params httprouter.Params) bool }
type XHandlerFunc ¶
type XHandlerFunc func(w http.ResponseWriter, r *http.Request, params httprouter.Params) bool
The XHandlerFunc type is an adapter to allow the use of ordinary functions as XHTTPHandlers. If f is a function with the appropriate signature, XHandlerFunc(f) is a Handler that calls f.
func (XHandlerFunc) Handle ¶
func (f XHandlerFunc) Handle(w http.ResponseWriter, r *http.Request, params httprouter.Params) bool