Documentation ¶
Index ¶
- func HttpRouteActionMatch(c *HttpContext, ra model.RouteAction) bool
- func HttpRouteMatch(c *HttpContext, rm model.RouterMatch) bool
- type ErrResponse
- type FilterChain
- type FilterFunc
- type HttpContext
- func (hc *HttpContext) API(api router.API)
- func (hc *HttpContext) Abort()
- func (hc *HttpContext) AbortWithError(message string, err error)
- func (hc *HttpContext) AddHeader(k, v string)
- func (hc *HttpContext) AllHeaders() http.Header
- func (hc *HttpContext) AppendFilterFunc(ff ...FilterFunc)
- func (hc *HttpContext) GetAPI() *router.API
- func (hc *HttpContext) GetApplicationName() string
- func (hc *HttpContext) GetClientIP() string
- func (hc *HttpContext) GetHeader(k string) string
- func (hc *HttpContext) GetMethod() string
- func (hc *HttpContext) GetRouteEntry() *model.RouteAction
- func (hc *HttpContext) GetUrl() string
- func (hc *HttpContext) Next()
- func (hc *HttpContext) Reset()
- func (hc *HttpContext) ResetWritermen(w http.ResponseWriter)
- func (hc *HttpContext) RouteEntry(r *model.RouteAction)
- func (hc *HttpContext) SetUrl(url string)
- func (hc *HttpContext) Status(code int)
- func (hc *HttpContext) StatusCode() int
- func (hc *HttpContext) Write(b []byte) (int, error)
- func (hc *HttpContext) WriteErr(p interface{})
- func (hc *HttpContext) WriteHeaderNow()
- func (hc *HttpContext) WriteJSONWithStatus(code int, res interface{})
- func (hc *HttpContext) WriteResponse(resp client.Response)
- func (hc *HttpContext) WriteSuccess()
- func (hc *HttpContext) WriteWithStatus(code int, b []byte) (int, error)
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HttpRouteActionMatch ¶
func HttpRouteActionMatch(c *HttpContext, ra model.RouteAction) bool
HttpRouteActionMatch
Types ¶
type ErrResponse ¶
type ErrResponse struct {
Message string `json:"message"`
}
ErrResponse err response.
type HttpContext ¶
type HttpContext struct { Index int8 Filters FilterChain Timeout time.Duration Ctx context.Context // the response context will return. TargetResp *client.Response // client call response. SourceResp interface{} // happen error Err error HttpConnectionManager model.HttpConnectionManagerConfig Listener *model.Listener Route *model.RouteAction Api *router.API Request *http.Request Writer ResponseWriter // contains filtered or unexported fields }
HttpContext http context
func (*HttpContext) API ¶
func (hc *HttpContext) API(api router.API)
API sets the API to http context
func (*HttpContext) Abort ¶
func (hc *HttpContext) Abort()
Abort filter chain break , filter after the current filter will not executed.
func (*HttpContext) AbortWithError ¶
func (hc *HttpContext) AbortWithError(message string, err error)
AbortWithError filter chain break , filter after the current filter will not executed. And log will print.
func (*HttpContext) AllHeaders ¶
func (hc *HttpContext) AllHeaders() http.Header
AllHeaders get all headers
func (*HttpContext) AppendFilterFunc ¶
func (hc *HttpContext) AppendFilterFunc(ff ...FilterFunc)
AppendFilterFunc append filter func.
func (*HttpContext) GetApplicationName ¶
func (hc *HttpContext) GetApplicationName() string
GetApplicationName get application name
func (*HttpContext) GetClientIP ¶
func (hc *HttpContext) GetClientIP() string
GetClientIP get client IP
func (*HttpContext) GetHeader ¶
func (hc *HttpContext) GetHeader(k string) string
GetHeader get header
func (*HttpContext) GetMethod ¶
func (hc *HttpContext) GetMethod() string
GetMethod get method, POST/GET ...
func (*HttpContext) GetRouteEntry ¶
func (hc *HttpContext) GetRouteEntry() *model.RouteAction
GetRouteEntry get route
func (*HttpContext) ResetWritermen ¶
func (hc *HttpContext) ResetWritermen(w http.ResponseWriter)
ResetWritermen reset writermen
func (*HttpContext) RouteEntry ¶
func (hc *HttpContext) RouteEntry(r *model.RouteAction)
RouteEntry set route
func (*HttpContext) SetUrl ¶
func (hc *HttpContext) SetUrl(url string)
func (*HttpContext) StatusCode ¶
func (hc *HttpContext) StatusCode() int
StatusCode get header status code
func (*HttpContext) Write ¶
func (hc *HttpContext) Write(b []byte) (int, error)
Write write body data
func (*HttpContext) WriteHeaderNow ¶
func (hc *HttpContext) WriteHeaderNow()
WriteHeaderNow write header now
func (*HttpContext) WriteJSONWithStatus ¶
func (hc *HttpContext) WriteJSONWithStatus(code int, res interface{})
WriteJSONWithStatus write fail, auto add context-type json.
func (*HttpContext) WriteResponse ¶
func (hc *HttpContext) WriteResponse(resp client.Response)
WriteResponse
func (*HttpContext) WriteWithStatus ¶
func (hc *HttpContext) WriteWithStatus(code int, b []byte) (int, error)
WriteWithStatus status must set first
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher // todo replace it later version // nolint http.CloseNotifier // Returns the HTTP response status code of the current request. Status() int // Returns the number of bytes already written into the response http body. // See Written() Size() int // Writes the string into the response body. WriteString(string) (int, error) // Returns true if the response body was already written. Written() bool // Forces to write the http header (status code + headers). WriteHeaderNow() // get the http.Pusher for server push Pusher() http.Pusher }
ResponseWriter ...