Documentation ¶
Overview ¶
Package context provides the context for traffic handlers.
Index ¶
- Constants
- func IsNetworkError(code int) bool
- type Context
- func (ctx *Context) AddTag(tag string)
- func (ctx *Context) CopyRequest(ns string)
- func (ctx *Context) CopyResponse(ns string)
- func (ctx *Context) Data() map[string]interface{}
- func (ctx *Context) Finish()
- func (ctx *Context) GetData(key string) interface{}
- func (ctx *Context) GetInputRequest() protocols.Request
- func (ctx *Context) GetInputResponse() protocols.Response
- func (ctx *Context) GetOutputRequest() protocols.Request
- func (ctx *Context) GetOutputResponse() protocols.Response
- func (ctx *Context) GetRequest(ns string) protocols.Request
- func (ctx *Context) GetResponse(ns string) protocols.Response
- func (ctx *Context) GetRoute() (protocols.Route, bool)
- func (ctx *Context) LazyAddTag(lazyTagFunc func() string)
- func (ctx *Context) Namespace() string
- func (ctx *Context) OnFinish(fn func())
- func (ctx *Context) Requests() map[string]protocols.Request
- func (ctx *Context) Responses() map[string]protocols.Response
- func (ctx *Context) SetData(key string, val interface{})
- func (ctx *Context) SetInputRequest(req protocols.Request)
- func (ctx *Context) SetInputResponse(resp protocols.Response)
- func (ctx *Context) SetOutputRequest(req protocols.Request)
- func (ctx *Context) SetOutputResponse(resp protocols.Response)
- func (ctx *Context) SetRequest(ns string, req protocols.Request)
- func (ctx *Context) SetResponse(ns string, resp protocols.Response)
- func (ctx *Context) SetRoute(route protocols.Route)
- func (ctx *Context) Span() *tracing.Span
- func (ctx *Context) Tags() string
- func (ctx *Context) UseNamespace(ns string)
- type Handler
- type MuxMapper
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 )
the error code list which align with the HTTP status code
const DefaultNamespace = "DEFAULT"
DefaultNamespace is the name of the default namespace.
Variables ¶
This section is empty.
Functions ¶
func IsNetworkError ¶
IsNetworkError returns if the error is network type.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds requests, responses and other data that need to be passed through the pipeline.
func (*Context) CopyRequest ¶
CopyRequest copies the request of namespace ns to the active namespace. The copied request is a new reference of the original request, that's they both point to the same underlying protocols.Request.
func (*Context) CopyResponse ¶
CopyResponse copies the response of namespace ns to the active namespace. The copied response is a new reference of the original response, that's they both point to the same underlying protocols.Response.
func (*Context) GetInputRequest ¶
GetInputRequest returns the request of the input namespace.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call GetOutputRequest when GetInputRequest is desired, or vice versa.
func (*Context) GetInputResponse ¶
GetInputResponse returns the response of the input namespace.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call GetOutputResponse when GetInputResponse is desired, or vice versa.
func (*Context) GetOutputRequest ¶
GetOutputRequest returns the request of the output namespace.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call GetInputRequest when GetOutputRequest is desired, or vice versa.
func (*Context) GetOutputResponse ¶
GetOutputResponse returns the response of the output namespace.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call GetInputResponse when GetOutputResponse is desired, or vice versa.
func (*Context) GetRequest ¶
GetRequest set the request of namespace ns to req.
func (*Context) GetResponse ¶
GetResponse returns the response of namespace ns.
func (*Context) LazyAddTag ¶
LazyAddTag add a tag to the Context in a lazy fashion.
func (*Context) OnFinish ¶
func (ctx *Context) OnFinish(fn func())
OnFinish registers a function to be called in Finish.
func (*Context) Requests ¶
Requests returns all requests, the caller should NOT modify the return value.
func (*Context) SetInputRequest ¶
SetInputRequest sets the request of the input namespace to req.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call SetOutputRequest when SetInputRequest is desired, or vice versa.
func (*Context) SetInputResponse ¶
SetInputResponse sets the response of the input namespace to resp.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call SetOutputResponse when SetInputResponse is desired, or vice versa.
func (*Context) SetOutputRequest ¶
SetOutputRequest sets the request of the output namespace to req.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call SetInputRequest when SetOutputRequest is desired, or vice versa.
func (*Context) SetOutputResponse ¶
SetOutputResponse sets the response of the output namespace to resp.
Currently, the output namespace is the same as the input namespace, but this may change in the future, code calling this function should be ready for the change and not to call SetInputResponse when SetOutputResponse is desired, or vice versa.
func (*Context) SetRequest ¶
SetRequest set the request of namespace ns to req.
func (*Context) SetResponse ¶
SetResponse set the response of namespace ns to resp.
func (*Context) UseNamespace ¶
UseNamespace sets the active namespace.
Directories ¶
Path | Synopsis |
---|---|
Package contexttest provides utilities for testing context.
|
Package contexttest provides utilities for testing context. |