Documentation
¶
Index ¶
- Constants
- Variables
- func FasthttpResponseToMotanResponse(motanResponse core.Response, fasthttpResponse *fasthttp.Response)
- func MotanRequestToFasthttpRequest(motanRequest core.Request, fasthttpRequest *fasthttp.Request, ...) error
- func PatternSplit(s string, pattern *regexp.Regexp) []string
- func ReleaseHttpMotanResponse(m *HttpMotanResponse)
- type HttpMotanResponse
- type LocationMatcher
- type ProxyLocation
- type ProxyMatchType
- type ProxyRewriteType
- type URIConverter
Constants ¶
const ( Proxy = "HTTP_PROXY" Method = "HTTP_Method" QueryString = "HTTP_QueryString" )
const ( HeaderPrefix = "http_" HeaderContentType = "Content-Type" HeaderContentTypeLowerCase = "content-type" HeaderHost = "Host" )
const ( DomainKey = "domain" KeepaliveTimeoutKey = "keepaliveTimeout" IdleConnectionTimeoutKey = "idleConnectionTimeout" ProxyAddressKey = "proxyAddress" ProxySchemaKey = "proxySchema" MaxConnectionsKey = "maxConnections" EnableRewriteKey = "enableRewrite" EnableHttpExceptionKey = "enableHttpException" )
const (
ProxyRequestIDKey = "requestIdFromClient"
)
Variables ¶
var ( WhitespaceSplitPattern = regexp.MustCompile(`\s+`) InnerAttachmentsConvertMap = map[string]string{ mpro.MPath: "MOTAN-p", mpro.MMethod: "MOTAN-m", mpro.MMethodDesc: "MOTAN-md", mpro.MGroup: "MOTAN-g", mpro.MProxyProtocol: "MOTAN-pp", mpro.MVersion: "MOTAN-v", mpro.MModule: "MOTAN-mdu", mpro.MSource: "MOTAN-s", mpro.MRequestID: "MOTAN-rid", mpro.MTimeout: "MOTAN-tmo", } )
Functions ¶
func FasthttpResponseToMotanResponse ¶
func FasthttpResponseToMotanResponse(motanResponse core.Response, fasthttpResponse *fasthttp.Response)
FasthttpResponseToMotanResponse convert a http response to a motan response For http mesh server side, the httpServer response to the server agent but client need a motan response Contrast to request convert, we put all headers to meta, an body maybe just use it with type []byte
func MotanRequestToFasthttpRequest ¶
func MotanRequestToFasthttpRequest(motanRequest core.Request, fasthttpRequest *fasthttp.Request, defaultHTTPMethod string) error
MotanRequestToFasthttpRequest convert a motan request to a fasthttp request For http mesh server side: rpc - motan2-> clientAgent - motan2 -> serverAgent - motan request convert to http request-> httpServer We use meta element HTTP_Method as http method, HTTP_QueryString as query string Request method as request uri Body will transform to a http body with following rules:
if body is a map[string]string we transform it as a form data if body is a string or []byte just use it else is unsupported
func ReleaseHttpMotanResponse ¶ added in v1.1.0
func ReleaseHttpMotanResponse(m *HttpMotanResponse)
Types ¶
type HttpMotanResponse ¶ added in v1.1.0
type HttpMotanResponse struct { core.MotanResponse HttpResponse *fasthttp.Response }
HttpMotanResponse Resposne used in http provider to deal with http response
func AcquireHttpMotanResponse ¶ added in v1.1.0
func AcquireHttpMotanResponse() *HttpMotanResponse
func (*HttpMotanResponse) Reset ¶ added in v1.1.0
func (m *HttpMotanResponse) Reset()
type LocationMatcher ¶
type LocationMatcher struct {
// contains filtered or unexported fields
}
func NewLocationMatcher ¶
func NewLocationMatcher(locations []*ProxyLocation) *LocationMatcher
func NewLocationMatcherFromContext ¶
func NewLocationMatcherFromContext(domain string, context *core.Context) *LocationMatcher
func (*LocationMatcher) NeedURLQueryString ¶
func (m *LocationMatcher) NeedURLQueryString() bool
func (*LocationMatcher) Pick ¶
Pick returns the matched upstream and do url rewrite and etc Now this functions just compatible with nginx location match rules See http://nginx.org/en/docs/http/ngx_http_core_module.html#location
func (*LocationMatcher) URIToServiceName ¶
func (m *LocationMatcher) URIToServiceName(uri string, queryString []byte) string
type ProxyLocation ¶
type ProxyLocation struct { Upstream string `yaml:"upstream"` Match string `yaml:"match"` Type string `yaml:"type"` RewriteRules []string `yaml:"rewriteRules"` // contains filtered or unexported fields }
func (*ProxyLocation) DeterminePath ¶
func (l *ProxyLocation) DeterminePath(path string, query []byte, doRewrite bool) string
type ProxyMatchType ¶
type ProxyMatchType uint8
func (ProxyMatchType) String ¶
func (t ProxyMatchType) String() string
type ProxyRewriteType ¶
type ProxyRewriteType uint8
func (ProxyRewriteType) String ¶
func (t ProxyRewriteType) String() string