Documentation ¶
Index ¶
Constants ¶
const ( EGStatusContinue = http.StatusContinue EGStatusSwitchingProtocols = http.StatusSwitchingProtocols EGStatusProcessing = http.StatusProcessing EGStatusOK = http.StatusOK EGStatusCreated = http.StatusCreated EGStatusAccepted = http.StatusAccepted EGStatusNoContent = http.StatusNoContent EGStatusPartialContent = http.StatusPartialContent EGStatusSpecialResponse = 300 // http.StatusMultipleChoices EGStatusMovedPermanently = http.StatusMovedPermanently EGStatusMovedTemporarily = 302 // http.StatusFound EGStatusSeeOther = http.StatusSeeOther EGStatusNotModified = http.StatusNotModified EGStatusTemporaryRedirect = http.StatusTemporaryRedirect EGStatusBadRequest = http.StatusBadRequest EGStatusForbidden = http.StatusForbidden EGStatusNotFound = http.StatusNotFound EGStatusNotAllowed = http.StatusMethodNotAllowed EGStatusRequestTimeOut = http.StatusRequestTimeout EGStatusConflict = http.StatusConflict EGStatusLengthRequired = http.StatusLengthRequired EGStatusPreconditionFailed = http.StatusPreconditionFailed EGStatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge EGStatusRequestURITooLong = http.StatusRequestURITooLong EGStatusUnsupportedMediaType = http.StatusUnsupportedMediaType EGStatusRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable EGStatusTooManyRequests = http.StatusTooManyRequests EGStatusClose = 444 EGStatusEgCodes = 494 EGStatusRequestHeaderTooLarge = 494 EGStatusHTTPSCertError = 495 EGStatusHTTPSNoCert = 496 EGStatusToHTTPS = 497 EGStatusClientClosedRequest = 499 EGStatusInternalServerError = http.StatusInternalServerError EGStatusNotImplemented = http.StatusNotImplemented EGStatusBadGateway = http.StatusBadGateway EGStatusGatewayTimeOut = http.StatusGatewayTimeout EGStatusInsufficientStorage = http.StatusInsufficientStorage EGStatusBadResponse = 599 )
Variables ¶
This section is empty.
Functions ¶
func IsNetworkError ¶
Types ¶
type BodyFlushFunc ¶
BodyFlushFunc is the type of function to be called back when body is flushing.
type FilterBuff ¶
FilterBuff stores filter's name and its YAML bytes
type FinishFunc ¶
type FinishFunc = func()
FinishFunc is the type of function to be called back when HTTPContext is finishing.
type HTTPContext ¶
type HTTPContext interface { Lock() Unlock() Span() tracing.Span Request() HTTPRequest Response() HTTPResponse stdcontext.Context Cancel(err error) Cancelled() bool ClientDisconnected() bool Duration() time.Duration // For log, sample, etc. OnFinish(func()) // For setting final client statistics, etc. AddTag(tag string) // For debug, log, etc. StatMetric() *httpstat.Metric Log() string Finish() Template() texttemplate.TemplateEngine SetTemplate(ht *HTTPTemplate) SaveReqToTemplate(filterName string) error SaveRspToTemplate(filterName string) error CallNextHandler(lastResult string) string SetHandlerCaller(caller HandlerCaller) }
HTTPContext is all context of an HTTP processing. It is not goroutine-safe, callers must use Lock/Unlock to protect it by themselves.
func New ¶
func New(stdw http.ResponseWriter, stdr *http.Request, tracer *tracing.Tracing, spanName string) HTTPContext
New creates an HTTPContext. NOTE: We can't use sync.Pool to recycle context. Reference: https://github.com/gin-gonic/gin/issues/1731
type HTTPRequest ¶
type HTTPRequest interface { RealIP() string Method() string SetMethod(method string) // URL Scheme() string Host() string SetHost(host string) Path() string SetPath(path string) EscapedPath() string Query() string SetQuery(query string) Fragment() string Proto() string Header() *httpheader.HTTPHeader Cookie(name string) (*http.Cookie, error) Cookies() []*http.Cookie AddCookie(cookie *http.Cookie) Body() io.Reader SetBody(io.Reader) Std() *http.Request Size() uint64 // bytes }
HTTPRequest is all operations for HTTP request.
type HTTPResponse ¶ added in v1.1.0
type HTTPResponse interface { StatusCode() int // Default is 200 SetStatusCode(code int) Header() *httpheader.HTTPHeader SetCookie(cookie *http.Cookie) SetBody(body io.Reader) Body() io.Reader OnFlushBody(func(body []byte, complete bool) (newBody []byte)) Std() http.ResponseWriter Size() uint64 // bytes }
HTTPResponse is all operations for HTTP response.
type HTTPTemplate ¶
type HTTPTemplate struct { Engine texttemplate.TemplateEngine // contains filtered or unexported fields }
HTTPTemplate is the wrapper of template engine for Easegress
func NewHTTPTemplate ¶
func NewHTTPTemplate(filterBuffs []FilterBuff) (*HTTPTemplate, error)
NewHTTPTemplate returns a default HTTPTemplate
func NewHTTPTemplateDummy ¶
func NewHTTPTemplateDummy() *HTTPTemplate
NewHTTPTemplateDummy return a empty implement version of HTTP template
func (*HTTPTemplate) Render ¶
func (e *HTTPTemplate) Render(input string) (string, error)
Render using engine to render template
func (*HTTPTemplate) SaveRequest ¶
func (e *HTTPTemplate) SaveRequest(filterName string, ctx HTTPContext) error
SaveRequest transforms HTTPRequest related fields into template engine's dictionary
func (*HTTPTemplate) SaveResponse ¶
func (e *HTTPTemplate) SaveResponse(filterName string, ctx HTTPContext) error
SaveResponse transforms HTTPResponse related fields into template engine's dictionary
type HandlerCaller ¶
HandlerCaller is a helper function to call the handler