Documentation ¶
Overview ¶
Package xgateway
@author: xwc1125
Package xgateway ¶
@author: xwc1125
Package xgateway ¶
@author: xwc1125
Package xgateway ¶
@author: xwc1125
Package xgateway ¶
@author: xwc1125
Index ¶
Constants ¶
View Source
const ( // Authentication HeaderAuthorization = "Authorization" HeaderProxyAuthenticate = "Proxy-Authenticate" HeaderProxyAuthorization = "Proxy-Authorization" HeaderWWWAuthenticate = "WWW-Authenticate" // Caching HeaderAge = "Age" HeaderCacheControl = "Cache-Control" HeaderClearSiteData = "Clear-Site-Data" HeaderExpires = "Expires" HeaderPragma = "Pragma" HeaderWarning = "Warning" // Client hints HeaderAcceptCH = "Accept-CH" HeaderAcceptCHLifetime = "Accept-CH-Lifetime" HeaderContentDPR = "Content-DPR" HeaderDPR = "DPR" HeaderEarlyData = "Early-Data" HeaderSaveData = "Save-Data" HeaderViewportWidth = "Viewport-Width" HeaderWidth = "Width" // Conditionals HeaderETag = "ETag" HeaderIfMatch = "If-Match" HeaderIfModifiedSince = "If-Modified-Since" HeaderIfNoneMatch = "If-None-Match" HeaderIfUnmodifiedSince = "If-Unmodified-Since" HeaderLastModified = "Last-Modified" HeaderVary = "Vary" // Connection management HeaderConnection = "Connection" HeaderKeepAlive = "Keep-Alive" HeaderProxyConnection = "Proxy-Connection" // Content negotiation HeaderAccept = "Accept" HeaderAcceptCharset = "Accept-Charset" HeaderAcceptEncoding = "Accept-Encoding" HeaderAcceptLanguage = "Accept-Language" // Controls HeaderCookie = "Cookie" HeaderExpect = "Expect" HeaderMaxForwards = "Max-Forwards" HeaderSetCookie = "Set-Cookie" // CORS HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderOrigin = "Origin" HeaderTimingAllowOrigin = "Timing-Allow-Origin" HeaderXPermittedCrossDomainPolicies = "X-Permitted-Cross-Domain-Policies" // Do Not Track HeaderDNT = "DNT" HeaderTk = "Tk" // Downloads HeaderContentDisposition = "Content-Disposition" // Message body information HeaderContentEncoding = "Content-Encoding" HeaderContentLanguage = "Content-Language" HeaderContentLength = "Content-Length" HeaderContentLocation = "Content-Location" HeaderContentType = "Content-Type" // Proxies HeaderForwarded = "Forwarded" HeaderVia = "Via" HeaderXForwardedFor = "X-Forwarded-For" // 标记通过代理访问服务器的原始客户端IP地址 HeaderXForwardedHost = "X-Forwarded-Host" // 标记通过代理访问服务器的原始客户端Host名 HeaderXForwardedProto = "X-Forwarded-Proto" // 标记原始客户端通过代理访问服务器时用的协议 HeaderXRealIP = "X-Real-IP" // 标记通过代理访问服务器的原始客户端IP地址 HeaderXRewriteOriginURI = "X-Rewrite-Origin-URI" // Redirects HeaderLocation = "Location" // Request context HeaderFrom = "From" HeaderHost = "Host" HeaderReferer = "Referer" HeaderReferrerPolicy = "Referrer-Policy" HeaderUserAgent = "User-Agent" // Response context HeaderAllow = "Allow" HeaderServer = "Server" // Range requests HeaderAcceptRanges = "Accept-Ranges" HeaderContentRange = "Content-Range" HeaderIfRange = "If-Range" HeaderRange = "Range" // Security HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderCrossOriginResourcePolicy = "Cross-Origin-Resource-Policy" HeaderExpectCT = "Expect-CT" HeaderFeaturePolicy = "Feature-Policy" HeaderPublicKeyPins = "Public-Key-Pins" HeaderPublicKeyPinsReportOnly = "Public-Key-Pins-Report-Only" HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderUpgradeInsecureRequests = "Upgrade-Insecure-Requests" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXDownloadOptions = "X-Download-Options" HeaderXFrameOptions = "X-Frame-Options" HeaderXPoweredBy = "X-Powered-By" // 标记框架、技术、环境等 HeaderXXSSProtection = "X-XSS-Protection" // Server-sent event HeaderLastEventID = "Last-Event-ID" HeaderNEL = "NEL" HeaderPingFrom = "Ping-From" HeaderPingTo = "Ping-To" HeaderReportTo = "Report-To" // Transfer coding HeaderTE = "TE" HeaderTrailer = "Trailer" HeaderTransferEncoding = "Transfer-Encoding" // WebSockets HeaderSecWebSocketAccept = "Sec-WebSocket-Accept" HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions" HeaderSecWebSocketKey = "Sec-WebSocket-Key" HeaderSecWebSocketProtocol = "Sec-WebSocket-Protocol" HeaderSecWebSocketVersion = "Sec-WebSocket-Version" // Other HeaderAcceptPatch = "Accept-Patch" HeaderAcceptPushPolicy = "Accept-Push-Policy" HeaderAcceptSignature = "Accept-Signature" HeaderAltSvc = "Alt-Svc" HeaderDate = "Date" HeaderIndex = "Index" HeaderLargeAllocation = "Large-Allocation" HeaderLink = "Link" HeaderPushPolicy = "Push-Policy" HeaderRetryAfter = "Retry-After" HeaderServerTiming = "Server-Timing" HeaderSignature = "Signature" HeaderSignedHeaders = "Signed-Headers" HeaderSourceMap = "SourceMap" HeaderUpgrade = "Upgrade" HeaderXDNSPrefetchControl = "X-DNS-Prefetch-Control" HeaderXPingback = "X-Pingback" HeaderXRequestedWith = "X-Requested-With" HeaderXRobotsTag = "X-Robots-Tag" HeaderXUACompatible = "X-UA-Compatible" )
Headers
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie interface { Key() []byte SetKey(key string) Value() []byte SetValue(value string) Path() []byte SetPath(path string) Domain() []byte SetDomain(domain string) Expire() time.Time SetExpire(expire time.Time) MaxAge() int SetMaxAge(seconds int) Secure() bool SetSecure(secure bool) HTTPOnly() bool SetHTTPOnly(httpOnly bool) SameSite() SameSite SetSameSite(mode SameSite) WriteTo(w io.Writer) (int64, error) Cookie() []byte String() string Valid() error }
type Header ¶
type Header interface { Add(key, value string) Set(key, value string) Del(key string) Get(key string) string ConnectionUpgrade() bool ContentLength() int SetContentLength(contentLength int) ContentType() []byte SetContentType(contentType string) ContentEncoding() []byte SetContentEncoding(contentEncoding string) Host() []byte SetHost(host string) UserAgent() []byte SetUserAgent(userAgent string) Method() []byte SetMethod(method string) Protocol() []byte SetProtocol(method string) RequestURI() []byte SetRequestURI(requestURI string) Cookie(key string) []byte AllCookie(f func(key, value []byte)) SetCookie(cookie Cookie) AddCookie(key, value string) DelCookie(key string) WriteTo(w io.Writer) (int64, error) Headers() []byte // resp StatusCode() int SetStatusCode(statusCode int) }
Header is like http.Header, but only implements the subset of its methods
type Request ¶
type Request interface { ID() uint64 Context() context.Context Header() Header Host() []byte SetHost(host string) RequestURI() []byte SetRequestURI(requestURI string) SetBody(body []byte) Body() ([]byte, error) AppendBody(p []byte) BodyWriteTo(w io.Writer) error WriteTo(w io.Writer) (int64, error) MultipartForm() (*multipart.Form, error) Cookies() []Cookie Cookie(name string) (Cookie, error) AddCookie(c Cookie) RemoteIP() net.IP Method() string Path() []byte SetPath([]byte) Args() url.Values }
type Response ¶
type Response interface { // ID returns the request id ID() uint32 // StatusCode returns the response code StatusCode() int // Header returns the response header. // // It allows you to add or set response headers before reaching the client. Header() Header // Var returns the value of a Nginx variable, like `r.Var("request_time")` // // To fetch the value, the runner will look up the request's cache first. If not found, // the runner will ask it from the APISIX. If the RPC call is failed, an error in // pkg/common.ErrConnClosed type is returned. Var(name string) ([]byte, error) // ReadBody returns origin HTTP response body // // To fetch the value, the runner will look up the request's cache first. If not found, // the runner will ask it from the APISIX. If the RPC call is failed, an error in // pkg/common.ErrConnClosed type is returned. // // It was not named `Body` // because `Body` was already occupied in earlier interface implementations. ReadBody() ([]byte, error) // Write rewrites the origin response data. // // Unlike `ResponseWriter.Write`, we don't need to WriteHeader(http.StatusOK) // before writing the data // Because APISIX will convert code 0 to 200. Write(b []byte) (int, error) // WriteHeader rewrites the origin response StatusCode // // WriteHeader can't override written status. WriteHeader(statusCode int) }
Response represents the HTTP response from the upstream received by APISIX. In order to avoid semantic misunderstanding, we also use Response to represent the rewritten response from Plugin Runner. Therefore, any instance that implements the Response interface will be readable and rewritable.
Click to show internal directories.
Click to hide internal directories.