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
- type LocationMatcher
- type ProxyLocation
- type ProxyMatchType
- type ProxyRewriteType
- type URIConverter
Constants ¶
const ( Proxy = "HTTP_PROXY" Method = "HTTP_Method" QueryString = "HTTP_QueryString" )
const ( DomainKey = "domain" KeepaliveTimeoutKey = "keepaliveTimeout" IdleConnectionTimeoutKey = "idleConnectionTimeout" ProxyAddressKey = "proxyAddress" ProxySchemaKey = "proxySchema" MaxConnectionsKey = "maxConnections" EnableRewriteKey = "enableRewrite" )
const (
ProxyRequestIDKey = "requestIdFromClient"
)
Variables ¶
var (
WhitespaceSplitPattern = regexp.MustCompile(`\s+`)
)
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
Types ¶
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