http

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Proxy       = "HTTP_PROXY"
	Method      = "HTTP_Method"
	QueryString = "HTTP_QueryString"
)
View Source
const (
	DomainKey                = "domain"
	KeepaliveTimeoutKey      = "keepaliveTimeout"
	IdleConnectionTimeoutKey = "idleConnectionTimeout"
	ProxyAddressKey          = "proxyAddress"
	ProxySchemaKey           = "proxySchema"
	MaxConnectionsKey        = "maxConnections"
	EnableRewriteKey         = "enableRewrite"
)
View Source
const (
	ProxyRequestIDKey = "requestIdFromClient"
)

Variables

View Source
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

func PatternSplit

func PatternSplit(s string, pattern *regexp.Regexp) []string

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

func (m *LocationMatcher) Pick(path string, query []byte, doRewrite bool) (string, string, bool)

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

type URIConverter

type URIConverter interface {
	URIToServiceName(uri string, queryStringBytes []byte) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL