/api/network
echo
- 🛠 回显请求内容
/api/network/echo
请求
ts
/**
* Forward proxy
*/
export interface IPayload {
/**
* Request method
*/
method?: string;
/**
* URL query parameters
*/
query?: URLSearchParams;
/**
* Request headers
*/
headers?: HeadersInit;
/**
* Request body
*/
body?: BodyInit;
}
响应
ts
/**
* Echo the content of the request
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
readonly Context: IContext;
readonly Request: IRequest;
readonly URL: IURL;
readonly User: IUser;
}
/**
* Request context
*/
export interface IContext {
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ClientIP}
*
* ClientIP implements one best effort algorithm to return the real client IP.
*
* It calls c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or
* not.
*
* If it is it will then try to parse the headers defined in Engine.RemoteIPHeaders
* (defaulting to [X-Forwarded-For, X-Real-Ip]).
*
* If the headers are not syntactically valid OR the remote IP does not correspond to a
* trusted proxy, the remote IP (coming from Request.RemoteAddr) is returned.
*/
readonly ClientIP: string;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ContentType}
*
* ContentType returns the Content-Type header of the request.
*/
readonly ContentType: string;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.FullPath}
*
* FullPath returns a matched route full path.
*
* For not found routes returns an empty string.
*/
readonly FullPath: string;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.HandlerNames}
*
* HandlerNames returns a list of all registered handlers for this context in descending
* order, following the semantics of HandlerName()
*/
readonly HandlerNames: string[];
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.IsWebsocket}
*
* IsWebsocket returns true if the request headers indicate that a websocket handshake is
* being initiated by the client.
*/
readonly IsWebsocket: boolean;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Params}
*
* Params is a Param-slice, as returned by the router.
*
* The slice is ordered, the first URL parameter is also the first slice value.
*
* It is therefore safe to read values by the index.
*/
readonly Params: IParam[] | null;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.GetRawData}
*
* GetRawData returns stream data.
*
* Use base64 encoding.
*/
readonly RawData: string;
/**
* {@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.RemoteIP}
*
* RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without
* the port).
*/
readonly RemoteIP: string;
}
/**
* Param is a single URL parameter, consisting of a key and a value.
*/
export interface IParam {
/**
* key name
*/
readonly Key: string;
/**
* key value
*/
readonly Value: string;
}
/**
* Request content
*/
export interface IRequest {
/**
* {@link https://pkg.go.dev/net/http#Request.Close}Close indicates whether to close the
* connection after replying to this request (for servers) or after sending this request and
* reading its response (for clients).
*
* For server requests, the HTTP server handles this automatically and this field is not
* needed by Handlers.
*
* For client requests, setting this field prevents re-use of TCP connections between
* requests to the same hosts, as if Transport.DisableKeepAlives were set.
*/
readonly Close: boolean;
/**
* {@link https://pkg.go.dev/net/http#Request.ContentLength}
*
* ContentLength records the length of the associated content.
*
* The value -1 indicates that the length is unknown.
*
* Values `>=` 0 indicate that the given number of bytes may be read from Body.
*
* For client requests, a value of 0 with a non-nil Body is also treated as unknown.
*/
readonly ContentLength: number;
/**
* {@link https://pkg.go.dev/net/http#Request.CookiesP}
*
* Cookies parses and returns the HTTP cookies sent with the request.
*/
readonly Cookies: ICookie[];
/**
* {@link https://pkg.go.dev/net/http#Request.Form}
*
* Form contains the parsed form data, including both the URL field's query parameters and
* the PATCH, POST, or PUT form data.
*
* This field is only available after ParseForm is called.
*
* The HTTP client ignores Form and uses Body instead.
*/
readonly Form: { [key: string]: string[] };
/**
* {@link https://pkg.go.dev/net/http#Request.Header}
*
* A Header represents the key-value pairs in an HTTP header.
*
* The keys should be in canonical form, as returned by CanonicalHeaderKey.
*/
readonly Header: { [key: string]: string[] };
/**
* {@link https://pkg.go.dev/net/http#Request.Host}
*
* For server requests, Host specifies the host on which the URL is sought. For HTTP/1 (per
* RFC 7230, section 5.4), this is either the value of the "Host" header or the host name
* given in the URL itself. For HTTP/2, it is the value of the ":authority" pseudo-header
* field.
*
* It may be of the form "host:port". For international domain names, Host may be in
* Punycode or Unicode form. Use golang.org/x/net/idna to convert it to either format if
* needed.
*
* To prevent DNS rebinding attacks, server Handlers should validate that the Host header
* has a value for which the Handler considers itself authoritative. The included
*
* ServeMux supports patterns registered to particular host names and thus protects its
* registered Handlers.
*
* For client requests, Host optionally overrides the Host header to send. If empty, the
* Request.Write method uses the value of URL.Host. Host may contain an international domain
* name.
*/
readonly Host: string;
/**
* {@link https://pkg.go.dev/net/http#Request.Method}
*
* Method specifies the HTTP method (GET, POST, PUT, etc.).
*
* For client requests, an empty string means GET.
*
* Go's HTTP client does not support sending a request with the CONNECT method. See the
* documentation on Transport for details.
*/
readonly Method: string;
/**
* {@link https://pkg.go.dev/mime/multipart#Form}
*
* Form is a parsed multipart form.
*
* Its File parts are stored either in memory or on disk,
*
* and are accessible via the *FileHeader's Open method.
*
* Its Value parts are stored as strings.
*
* Both are keyed by field name.
*/
readonly MultipartForm: IMultipartForm | null;
/**
* {@link https://pkg.go.dev/net/http#Request.PostForm}
*
* PostForm contains the parsed form data from PATCH, POST or PUT body parameters.
*
* This field is only available after ParseForm is called.
*
* The HTTP client ignores PostForm and uses Body instead.
*/
readonly PostForm: { [key: string]: string[] };
/**
* {@link https://pkg.go.dev/net/http#Request.Proto}
*
* The protocol version for incoming server requests.
*
* For client requests, these fields are ignored. The HTTP client code always uses either
* HTTP/1.1 or HTTP/2.
*
* See the docs on Transport for details.
*/
readonly Proto: string;
/**
* {@link https://pkg.go.dev/net/http#Request.ProtoMajor}
*/
readonly ProtoMajor: number;
/**
* {@link https://pkg.go.dev/net/http#Request.ProtoMinor}
*/
readonly ProtoMinor: number;
/**
* {@link https://pkg.go.dev/net/http#Request.RemoteAddr}
*
* Referer returns the referring URL, if sent in the request.
*
* Referer is misspelled as in the request itself, a mistake from the earliest days of
* HTTP. This value can also be fetched from the Header map as Header["Referer"]; the
* benefit of making it available as a method is that the compiler can diagnose programs
* that use the alternate (correct English) spelling req.Referrer() but cannot diagnose
* programs that use Header["Referrer"].
*/
readonly Referer: string;
/**
* {@link https://pkg.go.dev/net/http#Request.RemoteAddr}
*
* RemoteAddr allows HTTP servers and other software to record the network address that sent
* the request, usually for logging. This field is not filled in by ReadRequest and has no
* defined format. The HTTP server in this package sets RemoteAddr to an "IP:port" address
* before invoking a handler.
*
* This field is ignored by the HTTP client.
*/
readonly RemoteAddr: string;
/**
* {@link https://pkg.go.dev/net/http#Request.TLS}
*
* TLS allows HTTP servers and other software to record information about the TLS connection
* on which the request was received. This field is not filled in by ReadRequest.
*
* The HTTP server in this package sets the field for TLS-enabled connections before
* invoking a handler; otherwise it leaves the field nil.
*
* This field is ignored by the HTTP client.
*/
readonly TLS: Itls | null;
/**
* {@link https://pkg.go.dev/net/http#Request.Trailer}
*
* Trailer specifies additional headers that are sent after the request body.
*
* For server requests, the Trailer map initially contains only the tailer keys, with nil
* values. (The client declares which trailers it will later send.) While the handler is
* reading from Body, it must not reference Trailer. After reading from Body returns EOF,
* Trailer can be read again and will contain non-nil values, if they were sent by the
* client.
*
* For client requests, Trailer must be initialized to a map containing the trailer keys to
* later send. The values may be nil or their final values. The ContentLength must be 0 or
* -1, to send a chunked request.
*
* After the HTTP request is sent the map values can be updated while the request body is
* read. Once the body returns EOF, the caller must not mutate Trailer.
*
* Few HTTP clients, servers, or proxies support HTTP trailers.
*/
readonly Trailer: { [key: string]: string[] } | null;
/**
* {@link https://pkg.go.dev/net/http#Request.TransferEncoding}
*
* TransferEncoding lists the transfer encodings from outermost to innermost. An empty list
* denotes the "identity" encoding.
*
* TransferEncoding can usually be ignored; chunked encoding is automatically added and
* removed as necessary when sending and receiving requests.
*/
readonly TransferEncoding: string[] | null;
/**
* {@link https://pkg.go.dev/net/http#Request.URL}
*
* URL specifies either the URI being requested (for server requests) or the URL to access
* (for client requests).
*
* For server requests, the URL is parsed from the URI supplied on the Request-Line as
* stored in RequestURI. For most requests, fields other than Path and RawQuery will be
* empty. (See RFC 7230, Section 5.3)
*
* For client requests, the URL's Host specifies the server to connect to, while the
* Request's Host field optionally specifies the Host header value to send in the HTTP
* request.
*/
readonly URL: IRequestURL;
/**
* {@link https://pkg.go.dev/net/http#Request.UserAgent}
*
* UserAgent returns the client's User-Agent, if sent in the request.
*/
readonly UserAgent: string;
}
/**
* {@link https://pkg.go.dev/net/http#Cookie}
*
* A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an HTTP response
* or the Cookie header of an HTTP request.
*
* See https://tools.ietf.org/html/rfc6265 for details.
*/
export interface ICookie {
/**
* {@link https://pkg.go.dev/net/http#Cookie.Domain}
*
* Cookie efficient URL hostname
*/
readonly Domain: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Expires}
*
* Cookie expiration time (ISO 8601)
*/
readonly Expires: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.HttpOnly}
*
* Cookie HttpOnly flag
*/
readonly HttpOnly: boolean;
/**
* {@link https://pkg.go.dev/net/http#Cookie.MaxAge}
*
* - `MaxAge=0` means no 'Max-Age' attribute specified.
* - `MaxAge<0` means delete cookie now, equivalently 'Max-Age: 0'
* - `MaxAge>0` means 'Max-Age' attribute present and given in seconds
*/
readonly MaxAge: number;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Name}
*
* Cookie name
*/
readonly Name: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Path}
*
* Cookie efficient URL path
*/
readonly Path: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Raw}
*
* Raw text of this cookie
*/
readonly Raw: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.RawExpires}
*
* for reading cookies only
*/
readonly RawExpires: string;
/**
* {@link https://pkg.go.dev/net/http#Cookie.SameSite}
*
* Cookie SameSite flag
*
* - `1`: Default mode
* - `2`: Lax mode
* - `3`: Strict mode
* - `4`: None mode
*/
readonly SameSite: number;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Secure}
*
* Cookie Secure flag
*/
readonly Secure: boolean;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Unparsed}
*
* Raw text of unparsed attribute-value pairs
*/
readonly Unparsed: string[] | null;
/**
* {@link https://pkg.go.dev/net/http#Cookie.Value}
*
* Cookie value
*/
readonly Value: string;
}
/**
* multipart form data
*/
export interface IMultipartForm {
readonly File: { [key: string]: IFile[] };
readonly Value: { [key: string]: string[] };
}
/**
* multipart form file part
*/
export interface IFile {
/**
* File data encoded using base64
*/
readonly Content: string;
/**
* File name
*/
readonly Filename: string;
/**
* {@link https://pkg.go.dev/net/http#Header}
*
* A MIMEHeader represents a MIME-style header mapping keys to sets of values.
*/
readonly Header: { [key: string]: string[] };
/**
* File size (unit: byte)
*/
readonly Size: number;
}
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState}
*
* ConnectionState records basic TLS details about the connection.
*/
export interface Itls {
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.CipherSuite}
*
* CipherSuite is the cipher suite negotiated for the connection (e.g.
* TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_AES_128_GCM_SHA256).
*/
readonly CipherSuite: number;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.DidResume}
*
* DidResume is true if this connection was successfully resumed from a previous session
* with a session ticket or similar mechanism.
*/
readonly DidResume: boolean;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.HandshakeComplete}
*
* HandshakeComplete is true if the handshake has concluded.
*/
readonly HandshakeComplete: boolean;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocol}
*
* NegotiatedProtocol is the application protocol negotiated with ALPN.
*/
readonly NegotiatedProtocol: string;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}
*
* NegotiatedProtocolIsMutual used to indicate a mutual NPN negotiation.
*
* Deprecated: this value is always true.
*/
readonly NegotiatedProtocolIsMutual: boolean;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.OCSPResponse}
*
* OCSPResponse is a stapled Online Certificate Status Protocol (OCSP) response provided by
* the peer for the leaf certificate, if any.
*/
readonly OCSPResponse: any;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.PeerCertificates}
*
* PeerCertificates are the parsed certificates sent by the peer, in the order in which they
* were sent. The first element is the leaf certificate that the connection is verified
* against.
*
* On the client side, it can't be empty. On the server side, it can be empty if
* Config.ClientAuth is not RequireAnyClientCert or RequireAndVerifyClientCert.
*
* PeerCertificates and its contents should not be modified.
*/
readonly PeerCertificates: ICertificate[];
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}
*
* ServerName is the value of the Server Name Indication extension sent by the client. It's
* available both on the server and on the client side.
*/
readonly ServerName: string;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.SignedCertificateTimestamps}
*
* SignedCertificateTimestamps is a list of SCTs provided by the peer through the TLS
* handshake for the leaf certificate, if any.
*/
readonly SignedCertificateTimestamps: any;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.TLSUnique}
*
* TLSUnique contains the "tls-unique" channel binding value (see RFC 5929, Section 3).
* This value will be nil for TLS 1.3 connections and for resumed connections that don't
* support Extended Master Secret (RFC 7627).
*/
readonly TLSUnique: any;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.VerifiedChains}
*
* VerifiedChains is a list of one or more chains where the first element is
* PeerCertificates[0] and the last element is from Config.RootCAs (on the client side) or
* Config.ClientCAs (on the server side).
*
* On the client side, it's set if Config.InsecureSkipVerify is false. On the server side,
* it's set if Config.ClientAuth is VerifyClientCertIfGiven (and the peer provided a
* certificate) or RequireAndVerifyClientCert.
*
* VerifiedChains and its contents should not be modified.
*/
readonly VerifiedChains: Array<ICertificate[]>;
/**
* {@link https://pkg.go.dev/crypto/tls#ConnectionState.Version}
*
* Version is the TLS version used by the connection (e.g. VersionTLS12).
*/
readonly Version: number;
}
/**
* {@link https://pkg.go.dev/crypto/x509#Certificate}
*
* A Certificate represents an X.509 certificate.
*/
export interface ICertificate {
readonly Raw: any;
readonly RawTBSCertificate: any;
readonly RawSubjectPublicKeyInfo: any;
readonly RawSubject: any;
readonly RawIssuer: any;
readonly Signature: any;
readonly SignatureAlgorithm: any;
readonly PublicKeyAlgorithm: any;
readonly PublicKey: any;
readonly Version: any;
readonly SerialNumber: any;
readonly Issuer: any;
readonly Subject: any;
readonly NotBefore: any;
readonly KeyUsage: any;
readonly Extensions: any;
readonly ExtraExtensions: any;
readonly UnhandledCriticalExtensions: any;
readonly ExtKeyUsage: any;
readonly UnknownExtKeyUsage: any;
readonly BasicConstraintsValid: any;
readonly IsCA: any;
readonly MaxPathLen: any;
readonly MaxPathLenZero: any;
readonly SubjectKeyId: any;
readonly AuthorityKeyId: any;
readonly OCSPServer: any;
readonly IssuingCertificateURL: any;
readonly DNSNames: any;
readonly EmailAddresses: any;
readonly IPAddresses: any;
readonly URIs: any;
readonly PermittedDNSDomainsCritical: any;
readonly PermittedDNSDomains: any;
readonly ExcludedDNSDomains: any;
readonly PermittedIPRanges: any;
readonly ExcludedIPRanges: any;
readonly PermittedEmailAddresses: any;
readonly ExcludedEmailAddresses: any;
readonly PermittedURIDomains: any;
readonly ExcludedURIDomains: any;
readonly CRLDistributionPoints: any;
readonly PolicyIdentifiers: any;
[property: string]: any;
}
/**
* {@link https://pkg.go.dev/net/http#Request.URL}
*
* URL specifies either the URI being requested (for server requests) or the URL to access
* (for client requests).
*
* For server requests, the URL is parsed from the URI supplied on the Request-Line as
* stored in RequestURI. For most requests, fields other than Path and RawQuery will be
* empty. (See RFC 7230, Section 5.3)
*
* For client requests, the URL's Host specifies the server to connect to, while the
* Request's Host field optionally specifies the Host header value to send in the HTTP
* request.
*
* {@link https://pkg.go.dev/net/http#Request.URL}
*
* A URL represents a parsed URL (technically, a URI reference).
*
* The general form represented is:
*
* `[scheme:][//[userinfo@]host][/]path[?query][#fragment]`
*
* URLs that do not start with a slash after the scheme are interpreted as:
*
* `scheme:opaque[?query][#fragment]`
*
* Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.
*
* A consequence is that it is impossible to tell which slashes in the Path were slashes in
* the raw URL and which were %2f. This distinction is rarely important, but when it is, the
* code should use the EscapedPath method, which preserves the original encoding of Path.
*
* The RawPath field is an optional field which is only set when the default encoding of
* Path is different from the escaped path. See the EscapedPath method for more details.
*
* URL's String method uses the EscapedPath method to obtain the path.
*/
export interface IRequestURL {
/**
* {@link https://pkg.go.dev/net/url#URL.ForceQuery}
*
* append a query ('?') even if RawQuery is empty
*/
readonly ForceQuery: boolean;
/**
* {@link https://pkg.go.dev/net/url#URL.Fragment}
*
* fragment for references, without '#'
*/
readonly Fragment: string;
/**
* {@link https://pkg.go.dev/net/url#URL.Host}
*
* host or host:port
*/
readonly Host: string;
/**
* {@link https://pkg.go.dev/net/url#URL.OmitHost}
*
* do not emit empty host (authority)
*/
readonly OmitHost: boolean;
/**
* {@link https://pkg.go.dev/net/url#URL.Opaque}
*
* encoded opaque data
*/
readonly Opaque: string;
/**
* {@link https://pkg.go.dev/net/url#URL.Path}
*
* path (relative paths may omit leading slash)
*/
readonly Path: string;
/**
* {@link https://pkg.go.dev/net/url#URL.RawFragment}
*
* encoded fragment hint (see EscapedFragment method)
*/
readonly RawFragment: string;
/**
* {@link https://pkg.go.dev/net/url#URL.RawPath}
*
* encoded path hint (see EscapedPath method)
*/
readonly RawPath: string;
/**
* {@link https://pkg.go.dev/net/url#URL.RawQuery}
*
* encoded query values, without '?'
*/
readonly RawQuery: string;
/**
* {@link https://pkg.go.dev/net/url#URL.Scheme}
*
* URL schema
*/
readonly Scheme: string;
/**
* {@link https://pkg.go.dev/net/url#URL.User}
*
* username and password information
*/
readonly User: null;
[property: string]: any;
}
/**
* {@link https://pkg.go.dev/net/http#Request.URL}
*
* URL specifies either the URI being requested (for server requests) or the URL to access
* (for client requests).
*
* For server requests, the URL is parsed from the URI supplied on the Request-Line as
* stored in RequestURI. For most requests, fields other than Path and RawQuery will be
* empty. (See RFC 7230, Section 5.3)
*
* For client requests, the URL's Host specifies the server to connect to, while the
* Request's Host field optionally specifies the Host header value to send in the HTTP
* request.
*/
export interface IURL {
/**
* {@link https://pkg.go.dev/net/url#URL.EscapedFragment}
*
* EscapedFragment returns the escaped form of u.Fragment.
*
* In general there are multiple possible escaped forms of any fragment.
*
* EscapedFragment returns u.RawFragment when it is a valid escaping of u.Fragment.
*
* Otherwise EscapedFragment ignores u.RawFragment and computes an escaped form on its own.
*
* The String method uses EscapedFragment to construct its result.
*
* In general, code should call EscapedFragment instead of reading u.RawFragment directly.
*/
readonly EscapedFragment: string;
/**
* {@link https://pkg.go.dev/net/url#URL.EscapedPath}
*
* EscapedPath returns the escaped form of u.Path.
*
* In general there are multiple possible escaped forms of any path.
*
* EscapedPath returns u.RawPath when it is a valid escaping of u.Path.
*
* Otherwise EscapedPath ignores u.RawPath and computes an escaped form on its own.
*
* The String and RequestURI methods use EscapedPath to construct their results.
*
* In general, code should call EscapedPath instead of reading u.RawPath directly.
*/
readonly EscapedPath: string;
/**
* {@link https://pkg.go.dev/net/url#URL.Hostname}
*
* Hostname returns u.Host, stripping any valid port number if present.
*
* If the result is enclosed in square brackets, as literal IPv6 addresses are, the square
* brackets are removed from the result.
*/
readonly Hostname: string;
/**
* {@link https://pkg.go.dev/net/url#URL.IsAbs}
*
* IsAbs reports whether the URL is absolute.
*
* Absolute means that it has a non-empty scheme.
*/
readonly IsAbs: boolean;
/**
* {@link https://pkg.go.dev/net/url#URL.Port}
*
* Port returns the port part of u.Host, without the leading colon.
*
* If u.Host doesn't contain a valid numeric port, Port returns an empty string.
*/
readonly Port: string;
/**
* {@link https://pkg.go.dev/net/url#URL.Query}
*
* Query parses RawQuery and returns the corresponding values.
*
* It silently discards malformed value pairs.
*
* To check errors use ParseQuery.
*/
readonly Query: { [key: string]: string[] };
/**
* {@link https://pkg.go.dev/net/url#URL.Redacted}
*
* Redacted is like String but replaces any password with "xxxxx".
*
* Only the password in u.User is redacted.
*/
readonly Redacted: string;
/**
* {@link https://pkg.go.dev/net/url#URL.RequestURI}
*
* RequestURI returns the encoded path?query or opaque?query string that would be used in an
* HTTP request for u.
*/
readonly RequestURI: string;
/**
* {@link https://pkg.go.dev/net/url#URL.String}
*
* String reassembles the URL into a valid URL string.
*
* The general form of the result is one of:
* - `scheme:opaque?query#fragment`
* - `scheme://userinfo@host/path?query#fragment`
*
* If u.Opaque is non-empty, String uses the first form; otherwise it uses the second form.
*
* Any non-ASCII characters in host are escaped.
*
* To obtain the path, String uses u.EscapedPath().
*
* In the second form, the following rules apply:
* - if u.Scheme is empty, `scheme:` is omitted.
* - if u.User is nil, `userinfo@` is omitted.
* - if u.Host is empty, `host/` is omitted.
* - if u.Scheme and u.Host are empty and u.User is nil, the entire
* `scheme://userinfo@host/` is omitted.
* - if u.Host is non-empty and u.Path begins with a /, the form `host/path` does not add
* its own /.
* - if u.RawQuery is empty, `?query` is omitted.
* - if u.Fragment is empty, `#fragment` is omitted.
*/
readonly String: string;
}
/**
* Request user
*/
export interface IUser {
/**
* {@link https://pkg.go.dev/net/url#Userinfo.Password}
*
* Password returns the password in case it is set.
*/
readonly Password: string;
/**
* {@link https://pkg.go.dev/net/url#Userinfo.Password}
*
* Password returns the password whether it is set.
*/
readonly PasswordSet: boolean;
/**
* {@link https://pkg.go.dev/net/url#Userinfo.String}
*
* String returns the encoded userinfo information in the standard form of
* "username[:password]".
*/
readonly String: string;
/**
* {@link https://pkg.go.dev/net/url#Userinfo.Username}
*
* Username returns the username.
*/
readonly Username: string;
}
json5
/**
* schemas/kernel/api/network/echo/response.schema.json5
* 回显请求内容
* REF: https://github.com/siyuan-note/siyuan/blob/v2.11.0/kernel/api/network.go#L51-L151
* @pathname: /api/network/echo
* @version: 2.11.0
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/echo/response.schema.json5',
$comment: 'v2.11.0',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Echo the content of the request',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'Context',
'Request',
'URL',
'User',
],
properties: {
Context: {
// 请求上下文
$ref: '#/$defs/Context',
},
Request: {
// 请求内容
$ref: '#/$defs/Request',
},
URL: {
// 请求 URL
$ref: '#/$defs/URL',
},
User: {
// 请求用户
$ref: '#/$defs/User',
},
},
},
Context: {
title: 'IContext',
description: 'Request context',
type: 'object',
additionalProperties: false,
required: [
'ClientIP',
'ContentType',
'FullPath',
'HandlerNames',
'IsWebsocket',
'Params',
'RawData',
'RemoteIP',
],
properties: {
ClientIP: {
// 客户端 IP
type: 'string',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ClientIP}\
\n\n\
ClientIP implements one best effort algorithm to return the real client IP.\
\n\n\
It calls c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not.\
\n\n\
If it is it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]).\
\n\n\
If the headers are not syntactically valid OR the remote IP does not correspond to a trusted proxy, the remote IP (coming from Request.RemoteAddr) is returned.\
',
},
ContentType: {
// 请求内容类型
type: 'string',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ContentType}\
\n\n\
ContentType returns the Content-Type header of the request.\
',
},
FullPath: {
// URL 完整请求路径
type: 'string',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.FullPath}\
\n\n\
FullPath returns a matched route full path.\
\n\n\
For not found routes returns an empty string.\
',
},
HandlerNames: {
// Gin 服务器处理方法名称
type: 'array',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.HandlerNames}\
\n\n\
HandlerNames returns a list of all registered handlers for this context in descending order, following the semantics of HandlerName()\
',
items: {
type: 'string',
},
},
IsWebsocket: {
// 是否为 websocket 请求
type: 'boolean',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.IsWebsocket}\
\n\n\
IsWebsocket returns true if the request headers indicate that a websocket handshake is being initiated by the client.\
',
},
Params: {
// 路由参数
type: [
'array',
'null',
],
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Params}\
\n\n\
Params is a Param-slice, as returned by the router.\
\n\n\
The slice is ordered, the first URL parameter is also the first slice value.\
\n\n\
It is therefore safe to read values by the index.\
',
items: {
$ref: '#/$defs/Param',
},
},
RawData: {
// 使用 base64 编码的原始请求体内容
type: 'string',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.GetRawData}\
\n\n\
GetRawData returns stream data.\
\n\n\
Use base64 encoding.\
',
},
RemoteIP: {
// 远程 IP
type: 'string',
description: '\
{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.RemoteIP}\
\n\n\
RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port).\
',
},
},
},
Request: {
title: 'IRequest',
description: 'Request content',
type: 'object',
additionalProperties: false,
required: [
'Close',
'ContentLength',
'Cookies',
'Form',
'Header',
'Host',
'Method',
'MultipartForm',
'PostForm',
'Proto',
'ProtoMajor',
'ProtoMinor',
'Referer',
'RemoteAddr',
'TLS',
'Trailer',
'TransferEncoding',
'URL',
'UserAgent',
],
properties: {
Close: {
// 响应后连接是否关闭
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/http#Request.Close}\
Close indicates whether to close the connection after replying to this request (for servers) or after sending this request and reading its response (for clients).\
\n\n\
For server requests, the HTTP server handles this automatically and this field is not needed by Handlers.\
\n\n\
For client requests, setting this field prevents re-use of TCP connections between requests to the same hosts, as if Transport.DisableKeepAlives were set.\
',
},
ContentLength: {
// 请求体内容长度 (单位: 字节)
type: 'integer',
description: '\
{@link https://pkg.go.dev/net/http#Request.ContentLength}\
\n\n\
ContentLength records the length of the associated content.\
\n\n\
The value -1 indicates that the length is unknown.\
\n\n\
Values `>=` 0 indicate that the given number of bytes may be read from Body.\
\n\n\
For client requests, a value of 0 with a non-nil Body is also treated as unknown.\
',
},
Cookies: {
// HTTP Cookies
type: 'array',
description: '\
{@link https://pkg.go.dev/net/http#Request.CookiesP}\
\n\n\
Cookies parses and returns the HTTP cookies sent with the request.\
',
items: {
$ref: '#/$defs/Cookie',
},
},
Form: {
// 请求 Form 内容
description: "\
{@link https://pkg.go.dev/net/http#Request.Form}\
\n\n\
Form contains the parsed form data, including both the URL field's query parameters and the PATCH, POST, or PUT form data.\
\n\n\
This field is only available after ParseForm is called.\
\n\n\
The HTTP client ignores Form and uses Body instead.\
",
$ref: '#/$defs/Values',
},
Header: {
// HTTP 请求头
description: '\
{@link https://pkg.go.dev/net/http#Request.Header}\
\n\n\
A Header represents the key-value pairs in an HTTP header.\
\n\n\
The keys should be in canonical form, as returned by CanonicalHeaderKey.\
',
$ref: '#/$defs/Header',
},
Host: {
// 请求主机
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Request.Host}\
\n\n\
For server requests, Host specifies the host on which the URL is sought. For HTTP/1 (per RFC 7230, section 5.4), this is either the value of the "Host" header or the host name given in the URL itself. For HTTP/2, it is the value of the ":authority" pseudo-header field.\
\n\n\
It may be of the form "host:port". For international domain names, Host may be in Punycode or Unicode form. Use golang.org/x/net/idna to convert it to either format if needed.\
\n\n\
To prevent DNS rebinding attacks, server Handlers should validate that the Host header has a value for which the Handler considers itself authoritative. The included\
\n\n\
ServeMux supports patterns registered to particular host names and thus protects its registered Handlers.\
\n\n\
For client requests, Host optionally overrides the Host header to send. If empty, the Request.Write method uses the value of URL.Host. Host may contain an international domain name.\
',
},
Method: {
// HTTP 请求方法
type: 'string',
description: "\
{@link https://pkg.go.dev/net/http#Request.Method}\
\n\n\
Method specifies the HTTP method (GET, POST, PUT, etc.).\
\n\n\
For client requests, an empty string means GET.\
\n\n\
Go's HTTP client does not support sending a request with the CONNECT method. See the documentation on Transport for details.\
",
},
MultipartForm: {
// multipart/form-data 格式的请求体
description: "\
{@link https://pkg.go.dev/mime/multipart#Form}\
\n\n\
Form is a parsed multipart form.\
\n\n\
Its File parts are stored either in memory or on disk,\
\n\n\
and are accessible via the *FileHeader's Open method.\
\n\n\
Its Value parts are stored as strings.\
\n\n\
Both are keyed by field name.\
",
oneOf: [
{
$ref: '#/$defs/MultipartForm',
},
{
type: 'null',
},
],
},
PostForm: {
// application/x-www-form-urlencoded 格式的请求体
description: '\
{@link https://pkg.go.dev/net/http#Request.PostForm}\
\n\n\
PostForm contains the parsed form data from PATCH, POST or PUT body parameters.\
\n\n\
This field is only available after ParseForm is called.\
\n\n\
The HTTP client ignores PostForm and uses Body instead.\
',
$ref: '#/$defs/Values',
},
Proto: {
// HTTP 协议与版本
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Request.Proto}\
\n\n\
The protocol version for incoming server requests.\
\n\n\
For client requests, these fields are ignored. The HTTP client code always uses either HTTP/1.1 or HTTP/2.\
\n\n\
See the docs on Transport for details.\
',
},
ProtoMajor: {
// HTTP 主版本号
type: 'integer',
description: '\
{@link https://pkg.go.dev/net/http#Request.ProtoMajor}\
',
},
ProtoMinor: {
// HTTP 次版本号
type: 'integer',
description: '\
{@link https://pkg.go.dev/net/http#Request.ProtoMinor}\
',
},
Referer: {
// HTTP 请求来源页面地址
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Request.RemoteAddr}\
\n\n\
Referer returns the referring URL, if sent in the request.\
\n\n\
Referer is misspelled as in the request itself, a mistake from the earliest days of HTTP. This value can also be fetched from the Header map as Header["Referer"]; the benefit of making it available as a method is that the compiler can diagnose programs that use the alternate (correct English) spelling req.Referrer() but cannot diagnose programs that use Header["Referrer"].\
',
},
RemoteAddr: {
// 发送此请求的客户端地址
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Request.RemoteAddr}\
\n\n\
RemoteAddr allows HTTP servers and other software to record the network address that sent the request, usually for logging. This field is not filled in by ReadRequest and has no defined format. The HTTP server in this package sets RemoteAddr to an "IP:port" address before invoking a handler.\
\n\n\
This field is ignored by the HTTP client.\
',
description: '\
{@link https://pkg.go.dev/net/http#Request.RemoteAddr}\
\n\n\
RemoteAddr allows HTTP servers and other software to record the network address that sent the request, usually for logging. This field is not filled in by ReadRequest and has no defined format. The HTTP server in this package sets RemoteAddr to an "IP:port" address before invoking a handler.\
\n\n\
This field is ignored by the HTTP client.\
',
},
TLS: {
// TLS 连接状态
description: '\
{@link https://pkg.go.dev/net/http#Request.TLS}\
\n\n\
TLS allows HTTP servers and other software to record information about the TLS connection on which the request was received. This field is not filled in by ReadRequest.\
\n\n\
The HTTP server in this package sets the field for TLS-enabled connections before invoking a handler; otherwise it leaves the field nil.\
\n\n\
This field is ignored by the HTTP client.\
',
oneOf: [
{
$ref: '#/$defs/TLS',
},
{
type: 'null',
},
],
},
Trailer: {
// 请求体后附加的请求标头
description: '\
{@link https://pkg.go.dev/net/http#Request.Trailer}\
\n\n\
Trailer specifies additional headers that are sent after the request body.\
\n\n\
For server requests, the Trailer map initially contains only the tailer keys, with nil values. (The client declares which trailers it will later send.) While the handler is reading from Body, it must not reference Trailer. After reading from Body returns EOF, Trailer can be read again and will contain non-nil values, if they were sent by the client.\
\n\n\
For client requests, Trailer must be initialized to a map containing the trailer keys to later send. The values may be nil or their final values. The ContentLength must be 0 or -1, to send a chunked request.\
\n\n\
After the HTTP request is sent the map values can be updated while the request body is read. Once the body returns EOF, the caller must not mutate Trailer.\
\n\n\
Few HTTP clients, servers, or proxies support HTTP trailers.\
',
oneOf: [
{
$ref: '#/$defs/Header',
},
{
type: 'null',
},
],
},
TransferEncoding: {
// 从最外层到最内层的传输编码
type: [
'array',
'null',
],
description: '\
{@link https://pkg.go.dev/net/http#Request.TransferEncoding}\
\n\n\
TransferEncoding lists the transfer encodings from outermost to innermost. An empty list denotes the "identity" encoding.\
\n\n\
TransferEncoding can usually be ignored; chunked encoding is automatically added and removed as necessary when sending and receiving requests.\
',
items: {
type: 'string',
},
},
URL: {
// 请求 URL
description: "\
{@link https://pkg.go.dev/net/http#Request.URL}\
\n\n\
URL specifies either the URI being requested (for server requests) or the URL to access (for client requests).\
\n\n\
For server requests, the URL is parsed from the URI supplied on the Request-Line as stored in RequestURI. For most requests, fields other than Path and RawQuery will be empty. (See RFC 7230, Section 5.3)\
\n\n\
For client requests, the URL's Host specifies the server to connect to, while the Request's Host field optionally specifies the Host header value to send in the HTTP request.\
",
$ref: '#/$defs/RequestURL',
},
UserAgent: {
// 请求客户端的 User-Agent
type: 'string',
description: "\
{@link https://pkg.go.dev/net/http#Request.UserAgent}\
\n\n\
UserAgent returns the client's User-Agent, if sent in the request.\
",
},
},
},
URL: {
title: 'IUrl',
description: "\
{@link https://pkg.go.dev/net/http#Request.URL}\
\n\n\
URL specifies either the URI being requested (for server requests) or the URL to access (for client requests).\
\n\n\
For server requests, the URL is parsed from the URI supplied on the Request-Line as stored in RequestURI. For most requests, fields other than Path and RawQuery will be empty. (See RFC 7230, Section 5.3)\
\n\n\
For client requests, the URL's Host specifies the server to connect to, while the Request's Host field optionally specifies the Host header value to send in the HTTP request.\
",
type: 'object',
additionalProperties: false,
required: [
'EscapedFragment',
'EscapedPath',
'Hostname',
'IsAbs',
'Port',
'Query',
'Redacted',
'RequestURI',
'String',
],
properties: {
EscapedFragment: {
// 解码后的 URL 片段
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.EscapedFragment}\
\n\n\
EscapedFragment returns the escaped form of u.Fragment.\
\n\n\
In general there are multiple possible escaped forms of any fragment.\
\n\n\
EscapedFragment returns u.RawFragment when it is a valid escaping of u.Fragment.\
\n\n\
Otherwise EscapedFragment ignores u.RawFragment and computes an escaped form on its own.\
\n\n\
The String method uses EscapedFragment to construct its result.\
\n\n\
In general, code should call EscapedFragment instead of reading u.RawFragment directly.\
',
},
EscapedPath: {
// 解码后的 URL 路径
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.EscapedPath}\
\n\n\
EscapedPath returns the escaped form of u.Path.\
\n\n\
In general there are multiple possible escaped forms of any path.\
\n\n\
EscapedPath returns u.RawPath when it is a valid escaping of u.Path.\
\n\n\
Otherwise EscapedPath ignores u.RawPath and computes an escaped form on its own.\
\n\n\
The String and RequestURI methods use EscapedPath to construct their results.\
\n\n\
In general, code should call EscapedPath instead of reading u.RawPath directly.\
',
},
Hostname: {
// URL 目标主机名
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Hostname}\
\n\n\
Hostname returns u.Host, stripping any valid port number if present.\
\n\n\
If the result is enclosed in square brackets, as literal IPv6 addresses are, the square brackets are removed from the result.\
',
},
IsAbs: {
// 判断 ULR 路径是否为绝对路径
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/url#URL.IsAbs}\
\n\n\
IsAbs reports whether the URL is absolute.\
\n\n\
Absolute means that it has a non-empty scheme.\
',
},
Port: {
// URL 端口号
type: 'string',
description: "\
{@link https://pkg.go.dev/net/url#URL.Port}\
\n\n\
Port returns the port part of u.Host, without the leading colon.\
\n\n\
If u.Host doesn't contain a valid numeric port, Port returns an empty string.\
",
},
Query: {
// URL 查询参数
description: '\
{@link https://pkg.go.dev/net/url#URL.Query}\
\n\n\
Query parses RawQuery and returns the corresponding values.\
\n\n\
It silently discards malformed value pairs.\
\n\n\
To check errors use ParseQuery.\
',
$ref: '#/$defs/Values',
},
Redacted: {
// 将 URL 中的密码字段替换为 xxxxx 的 URL 字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Redacted}\
\n\n\
Redacted is like String but replaces any password with "xxxxx".\
\n\n\
Only the password in u.User is redacted.\
',
},
RequestURI: {
// 编码后的完整 URL 路径+查询字符串 (path?query 或 opaque?query)
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.RequestURI}\
\n\n\
RequestURI returns the encoded path?query or opaque?query string that would be used in an HTTP request for u.\
',
},
String: {
// 编码后的有效 URL 字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.String}\
\n\n\
String reassembles the URL into a valid URL string.\
\n\n\
The general form of the result is one of:\
\n- `scheme:opaque?query#fragment`\
\n- `scheme://userinfo@host/path?query#fragment`\
\n\n\
If u.Opaque is non-empty, String uses the first form; otherwise it uses the second form.\
\n\n\
Any non-ASCII characters in host are escaped.\
\n\n\
To obtain the path, String uses u.EscapedPath().\
\n\n\
In the second form, the following rules apply:\
\n- if u.Scheme is empty, `scheme:` is omitted.\
\n- if u.User is nil, `userinfo@` is omitted.\
\n- if u.Host is empty, `host/` is omitted.\
\n- if u.Scheme and u.Host are empty and u.User is nil, the entire `scheme://userinfo@host/` is omitted.\
\n- if u.Host is non-empty and u.Path begins with a /, the form `host/path` does not add its own /.\
\n- if u.RawQuery is empty, `?query` is omitted.\
\n- if u.Fragment is empty, `#fragment` is omitted.\
',
},
},
},
User: {
title: 'IUser',
description: 'Request user',
type: 'object',
additionalProperties: false,
required: [
'Password',
'PasswordSet',
'String',
'Username',
],
properties: {
Password: {
// 密码
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#Userinfo.Password}\
\n\n\
Password returns the password in case it is set.\
',
},
PasswordSet: {
// 判断是否设置了密码
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/url#Userinfo.Password}\
\n\n\
Password returns the password whether it is set.\
',
},
String: {
// 编码后的完整用户名密码字段 username[:password]
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#Userinfo.String}\
\n\n\
String returns the encoded userinfo information in the standard form of "username[:password]".\
',
},
Username: {
// 用户名
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#Userinfo.Username}\
\n\n\
Username returns the username.\
',
},
},
},
Param: {
// 查询参数
title: 'IParam',
description: 'Param is a single URL parameter, consisting of a key and a value.',
type: 'object',
additionalProperties: false,
required: [
'Key',
'Value',
],
properties: {
Key: {
// 键名
type: 'string',
description: 'key name',
},
Value: {
// 键值
type: 'string',
description: 'key value',
},
},
},
Cookie: {
// HTTP Cookie
title: 'ICookie',
description: '\
{@link https://pkg.go.dev/net/http#Cookie}\
\n\n\
A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an HTTP response or the Cookie header of an HTTP request.\
\n\n\
See https://tools.ietf.org/html/rfc6265 for details.\
',
type: 'object',
additionalProperties: false,
required: [
'Name',
'Value',
'Path',
'Domain',
'Expires',
'RawExpires',
'MaxAge',
'Secure',
'HttpOnly',
'SameSite',
'Raw',
'Unparsed',
],
properties: {
Name: {
// Cookie 名称
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Name}\
\n\n\
Cookie name\
',
},
Value: {
// Cookie 值
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Value}\
\n\n\
Cookie value\
',
},
Path: {
// Cookie 生效的 URL 路径
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Path}\
\n\n\
Cookie efficient URL path\
',
},
Domain: {
// Cookie 生效的 URL 主机名 (站点域名)
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Domain}\
\n\n\
Cookie efficient URL hostname\
',
},
Expires: {
// Cookie 过期时间 (ISO-8601 格式)
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Expires}\
\n\n\
Cookie expiration time (ISO 8601)\
',
pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-6][0-9]:[0-6][0-9](\\.[0-9]+)?Z$',
},
RawExpires: {
// Cookie 过期时间原始字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.RawExpires}\
\n\n\
for reading cookies only\
',
},
MaxAge: {
// Cookie 有效期
type: 'integer',
description: "\
{@link https://pkg.go.dev/net/http#Cookie.MaxAge}\
\n\
\n- `MaxAge=0` means no 'Max-Age' attribute specified.\
\n- `MaxAge<0` means delete cookie now, equivalently 'Max-Age: 0'\
\n- `MaxAge>0` means 'Max-Age' attribute present and given in seconds\
",
},
Secure: {
// Cookie Secure 标记 (是否只用于 HTTPS 请求)
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Secure}\
\n\n\
Cookie Secure flag\
',
},
HttpOnly: {
// Cookie HttpOnly 标记 (是否禁止 JavaScript 访问)
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.HttpOnly}\
\n\n\
Cookie HttpOnly flag\
',
},
SameSite: {
// Cookie SameSite 标记 (是否禁止第三方网站访问)
type: 'integer',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.SameSite}\
\n\n\
Cookie SameSite flag\
\n\
\n- `1`: Default mode\
\n- `2`: Lax mode\
\n- `3`: Strict mode\
\n- `4`: None mode\
',
enum: [
1, // Default (Lax)
2, // Lax: cookie 不会在跨站请求中被发送
3, // Strict: 浏览器仅对同一站点的请求发送 cookie
4, // None: 浏览器会在跨站和同站请求中均发送 cookie
],
},
Raw: {
// Cookie 原始字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Raw}\
\n\n\
Raw text of this cookie\
',
},
Unparsed: {
// Cookie 未解析的属性值对的原始文本
type: [
'array',
'null',
],
description: '\
{@link https://pkg.go.dev/net/http#Cookie.Unparsed}\
\n\n\
Raw text of unparsed attribute-value pairs\
',
items: {
type: 'string',
},
},
},
},
Values: {
// 字符串键到字符串列表的映射
title: 'IValues',
description: '\
{@link https://pkg.go.dev/net/url#Values}\
\n\n\
Values maps a string key to a list of values.\
\n\n\
It is typically used for query parameters and form values.\
\n\n\
Unlike in the http.Header map, the keys in a Values map are case-sensitive.\
',
type: 'object',
propertyNames: {
type: 'string',
},
additionalProperties: {
type: 'array',
items: {
type: 'string',
},
},
},
Header: {
// HTTP 请求标头
title: 'IHeader',
description: '\
{@link https://pkg.go.dev/net/http#Request.Header}\
\n\n\
Header contains the request header fields either received by the server or to be sent by the client.\
\n\n\
If a server received a request with header lines,\
\n```http\
\nHost: example.com\
\naccept-encoding: gzip, deflate\
\nAccept-Language: en-us\
\nfOO: Bar\
\nfoo: two\
\n```\
\nthen\
\n```json\
\n{\
\n "Accept-Encoding": ["gzip, deflate"],\
\n "Accept-Language": ["en-us"],\
\n "Foo": ["Bar", "two"],\
\n}\
\n```\
For incoming requests, the Host header is promoted to the Request.Host field and removed from the Header map.\
\n\n\
HTTP defines that header names are case-insensitive. The request parser implements this by using CanonicalHeaderKey, making the first character and any characters following a hyphen uppercase and the rest lowercase.\
\n\n\
For client requests, certain headers such as Content-Length and Connection are automatically written when needed and values in Header may be ignored. See the documentation for the Request.Write method.\
',
type: 'object',
propertyNames: {
type: 'string',
},
additionalProperties: {
type: 'array',
items: {
type: 'string',
},
},
},
MultipartForm: {
// 多部分表单数据
title: 'IMultipartForm',
description: 'multipart form data',
type: 'object',
additionalProperties: false,
required: [
'Value',
'File',
],
properties: {
Value: {
$ref: '#/$defs/Values',
},
File: {
$ref: '#/$defs/MultipartFormFile',
},
},
},
MultipartFormFile: {
// 多部分表单文件数据
title: 'IMultipartFormFile',
description: 'multipart form file data',
type: 'object',
propertyNames: {
type: 'string',
},
additionalProperties: {
type: 'array',
items: {
$ref: '#/$defs/File',
},
},
},
File: {
// 多部分表单文件
title: 'IFile',
description: 'multipart form file part',
type: 'object',
additionalProperties: false,
required: [
'Content',
'Filename',
'Header',
'Size',
],
properties: {
Content: {
// 使用 base64 编码的文件数据
type: 'string',
description: 'File data encoded using base64',
},
Filename: {
// 文件名
type: 'string',
description: 'File name',
},
Header: {
// 文件部分 MIME 标识头
description: '\
{@link https://pkg.go.dev/net/http#Header}\
\n\n\
A MIMEHeader represents a MIME-style header mapping keys to sets of values.\
',
$ref: '#/$defs/Header',
},
Size: {
// 文件大小 (单位: 字节)
type: 'integer',
description: 'File size (unit: byte)',
minimum: 0,
},
},
},
RequestURL: {
// 请求 URL
title: 'IRequestURL',
description: "\
{@link https://pkg.go.dev/net/http#Request.URL}\
\n\n\
A URL represents a parsed URL (technically, a URI reference).\
\n\n\
The general form represented is:\
\n\n\
`[scheme:][//[userinfo@]host][/]path[?query][#fragment]`\
\n\n\
URLs that do not start with a slash after the scheme are interpreted as:\
\n\n\
`scheme:opaque[?query][#fragment]`\
\n\n\
Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\
\n\n\
A consequence is that it is impossible to tell which slashes in the Path were slashes in the raw URL and which were %2f. This distinction is rarely important, but when it is, the code should use the EscapedPath method, which preserves the original encoding of Path.\
\n\n\
The RawPath field is an optional field which is only set when the default encoding of Path is different from the escaped path. See the EscapedPath method for more details.\
\n\n\
URL's String method uses the EscapedPath method to obtain the path.\
",
type: 'object',
required: [
'Scheme',
'Opaque',
'User',
'Host',
'Path',
'RawPath',
'OmitHost',
'ForceQuery',
'RawQuery',
'Fragment',
'RawFragment',
],
properties: {
Scheme: {
// URL 协议
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Scheme}\
\n\n\
URL schema\
',
},
Opaque: {
// 不透明数据
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Opaque}\
\n\n\
encoded opaque data\
',
},
User: {
// 用户名
type: 'null',
description: '\
{@link https://pkg.go.dev/net/url#URL.User}\
\n\n\
username and password information\
',
},
Host: {
// 主机名
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Host}\
\n\n\
host or host:port\
',
},
Path: {
// URL 路径
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.Path}\
\n\n\
path (relative paths may omit leading slash)\
',
},
RawPath: {
// URL 路径原始字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.RawPath}\
\n\n\
encoded path hint (see EscapedPath method)\
',
},
OmitHost: {
// 是否省略主机名
type: 'boolean',
description: '\
{@link https://pkg.go.dev/net/url#URL.OmitHost}\
\n\n\
do not emit empty host (authority)\
',
},
ForceQuery: {
// 是否强制使用查询字符串
type: 'boolean',
description: "\
{@link https://pkg.go.dev/net/url#URL.ForceQuery}\
\n\n\
append a query ('?') even if RawQuery is empty\
",
},
RawQuery: {
// URL 查询字符串原始字符串
type: 'string',
description: "\
{@link https://pkg.go.dev/net/url#URL.RawQuery}\
\n\n\
encoded query values, without '?'\
",
},
Fragment: {
// URL 片段
type: 'string',
description: "\
{@link https://pkg.go.dev/net/url#URL.Fragment}\
\n\n\
fragment for references, without '#'\
",
},
RawFragment: {
// URL 片段原始字符串
type: 'string',
description: '\
{@link https://pkg.go.dev/net/url#URL.RawFragment}\
\n\n\
encoded fragment hint (see EscapedFragment method)\
',
},
},
},
TLS: {
// 连接状态
title: 'ITLS',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState}\
\n\n\
ConnectionState records basic TLS details about the connection.\
',
type: 'object',
additionalProperties: false,
required: [
'Version',
'HandshakeComplete',
'DidResume',
'CipherSuite',
'NegotiatedProtocol',
'NegotiatedProtocolIsMutual',
'ServerName',
'PeerCertificates',
'VerifiedChains',
'SignedCertificateTimestamps',
'OCSPResponse',
'TLSUnique',
],
properties: {
Version: {
// TLS 版本
type: 'integer',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.Version}\
\n\n\
Version is the TLS version used by the connection (e.g. VersionTLS12).\
',
minimum: 0,
},
HandshakeComplete: {
// 是否完成握手
type: 'boolean',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.HandshakeComplete}\
\n\n\
HandshakeComplete is true if the handshake has concluded.\
',
},
DidResume: {
// 是否恢复会话
type: 'boolean',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.DidResume}\
\n\n\
DidResume is true if this connection was successfully resumed from a previous session with a session ticket or similar mechanism.\
',
},
CipherSuite: {
// 加密套件
type: 'integer',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.CipherSuite}\
\n\n\
CipherSuite is the cipher suite negotiated for the connection (e.g. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_AES_128_GCM_SHA256).\
',
minimum: 0,
},
NegotiatedProtocol: {
// 协商的协议
type: 'string',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocol}\
\n\n\
NegotiatedProtocol is the application protocol negotiated with ALPN.\
',
},
NegotiatedProtocolIsMutual: {
// 是否为双向协商
type: 'boolean',
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}\
\n\n\
NegotiatedProtocolIsMutual used to indicate a mutual NPN negotiation.\
\n\n\
Deprecated: this value is always true.\
',
},
ServerName: {
// 服务器名称
type: 'string',
description: "\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}\
\n\n\
ServerName is the value of the Server Name Indication extension sent by the client. It's available both on the server and on the client side.\
",
},
PeerCertificates: {
// 对等证书
type: 'array',
description: "\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.PeerCertificates}\
\n\n\
PeerCertificates are the parsed certificates sent by the peer, in the order in which they were sent. The first element is the leaf certificate that the connection is verified against.\
\n\n\
On the client side, it can't be empty. On the server side, it can be empty if Config.ClientAuth is not RequireAnyClientCert or RequireAndVerifyClientCert.\
\n\n\
PeerCertificates and its contents should not be modified.\
",
items: {
$ref: '#/$defs/Certificate',
},
},
VerifiedChains: {
// 已验证的证书链
type: 'array',
description: "\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.VerifiedChains}\
\n\n\
VerifiedChains is a list of one or more chains where the first element is PeerCertificates[0] and the last element is from Config.RootCAs (on the client side) or Config.ClientCAs (on the server side).\
\n\n\
On the client side, it's set if Config.InsecureSkipVerify is false. On the server side, it's set if Config.ClientAuth is VerifyClientCertIfGiven (and the peer provided a certificate) or RequireAndVerifyClientCert.\
\n\n\
VerifiedChains and its contents should not be modified.\
",
items: {
type: 'array',
items: {
$ref: '#/$defs/Certificate',
},
},
},
SignedCertificateTimestamps: {
// 签名证书时间戳
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.SignedCertificateTimestamps}\
\n\n\
SignedCertificateTimestamps is a list of SCTs provided by the peer through the TLS handshake for the leaf certificate, if any.\
',
},
OCSPResponse: {
// OCSP 响应
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.OCSPResponse}\
\n\n\
OCSPResponse is a stapled Online Certificate Status Protocol (OCSP) response provided by the peer for the leaf certificate, if any.\
',
},
TLSUnique: {
// TLS 唯一标识
description: '\
{@link https://pkg.go.dev/crypto/tls#ConnectionState.TLSUnique}\
\n\n\
TLSUnique contains the "tls-unique" channel binding value (see RFC 5929, Section 3).\
\n\
This value will be nil for TLS 1.3 connections and for resumed connections that don\'t support Extended Master Secret (RFC 7627).\
',
},
},
},
Certificate: {
// X.509 证书
title: 'ICertificate',
description: '\
{@link https://pkg.go.dev/crypto/x509#Certificate}\
\n\n\
A Certificate represents an X.509 certificate.\
',
type: 'object',
required: [
'Raw',
'RawTBSCertificate',
'RawSubjectPublicKeyInfo',
'RawSubject',
'RawIssuer',
'Signature',
'SignatureAlgorithm',
'PublicKeyAlgorithm',
'PublicKey',
'Version',
'SerialNumber',
'Issuer',
'Subject',
'NotBefore',
'KeyUsage',
'Extensions',
'ExtraExtensions',
'UnhandledCriticalExtensions',
'ExtKeyUsage',
'UnknownExtKeyUsage',
'BasicConstraintsValid',
'IsCA',
'MaxPathLen',
'MaxPathLenZero',
'SubjectKeyId',
'AuthorityKeyId',
'OCSPServer',
'IssuingCertificateURL',
'DNSNames',
'EmailAddresses',
'IPAddresses',
'URIs',
'PermittedDNSDomainsCritical',
'PermittedDNSDomains',
'ExcludedDNSDomains',
'PermittedIPRanges',
'ExcludedIPRanges',
'PermittedEmailAddresses',
'ExcludedEmailAddresses',
'PermittedURIDomains',
'ExcludedURIDomains',
'CRLDistributionPoints',
'PolicyIdentifiers',
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/echo/response.schema.json",
"$comment": "v2.11.0",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Echo the content of the request",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"Context",
"Request",
"URL",
"User"
],
"properties": {
"Context": {
"$ref": "#/$defs/Context"
},
"Request": {
"$ref": "#/$defs/Request"
},
"URL": {
"$ref": "#/$defs/URL"
},
"User": {
"$ref": "#/$defs/User"
}
}
},
"Context": {
"title": "IContext",
"description": "Request context",
"type": "object",
"additionalProperties": false,
"required": [
"ClientIP",
"ContentType",
"FullPath",
"HandlerNames",
"IsWebsocket",
"Params",
"RawData",
"RemoteIP"
],
"properties": {
"ClientIP": {
"type": "string",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ClientIP}\n\nClientIP implements one best effort algorithm to return the real client IP.\n\nIt calls c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not.\n\nIf it is it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]).\n\nIf the headers are not syntactically valid OR the remote IP does not correspond to a trusted proxy, the remote IP (coming from Request.RemoteAddr) is returned."
},
"ContentType": {
"type": "string",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.ContentType}\n\nContentType returns the Content-Type header of the request."
},
"FullPath": {
"type": "string",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.FullPath}\n\nFullPath returns a matched route full path.\n\nFor not found routes returns an empty string."
},
"HandlerNames": {
"type": "array",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.HandlerNames}\n\nHandlerNames returns a list of all registered handlers for this context in descending order, following the semantics of HandlerName()",
"items": {
"type": "string"
}
},
"IsWebsocket": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.IsWebsocket}\n\nIsWebsocket returns true if the request headers indicate that a websocket handshake is being initiated by the client."
},
"Params": {
"type": [
"array",
"null"
],
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Params}\n\nParams is a Param-slice, as returned by the router.\n\nThe slice is ordered, the first URL parameter is also the first slice value.\n\nIt is therefore safe to read values by the index.",
"items": {
"$ref": "#/$defs/Param"
}
},
"RawData": {
"type": "string",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.GetRawData}\n\nGetRawData returns stream data.\n\nUse base64 encoding."
},
"RemoteIP": {
"type": "string",
"description": "{@link https://pkg.go.dev/github.com/gin-gonic/gin@v1.9.1#Context.RemoteIP}\n\nRemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port)."
}
}
},
"Request": {
"title": "IRequest",
"description": "Request content",
"type": "object",
"additionalProperties": false,
"required": [
"Close",
"ContentLength",
"Cookies",
"Form",
"Header",
"Host",
"Method",
"MultipartForm",
"PostForm",
"Proto",
"ProtoMajor",
"ProtoMinor",
"Referer",
"RemoteAddr",
"TLS",
"Trailer",
"TransferEncoding",
"URL",
"UserAgent"
],
"properties": {
"Close": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/http#Request.Close}Close indicates whether to close the connection after replying to this request (for servers) or after sending this request and reading its response (for clients).\n\nFor server requests, the HTTP server handles this automatically and this field is not needed by Handlers.\n\nFor client requests, setting this field prevents re-use of TCP connections between requests to the same hosts, as if Transport.DisableKeepAlives were set."
},
"ContentLength": {
"type": "integer",
"description": "{@link https://pkg.go.dev/net/http#Request.ContentLength}\n\nContentLength records the length of the associated content.\n\nThe value -1 indicates that the length is unknown.\n\nValues `>=` 0 indicate that the given number of bytes may be read from Body.\n\nFor client requests, a value of 0 with a non-nil Body is also treated as unknown."
},
"Cookies": {
"type": "array",
"description": "{@link https://pkg.go.dev/net/http#Request.CookiesP}\n\nCookies parses and returns the HTTP cookies sent with the request.",
"items": {
"$ref": "#/$defs/Cookie"
}
},
"Form": {
"description": "{@link https://pkg.go.dev/net/http#Request.Form}\n\nForm contains the parsed form data, including both the URL field's query parameters and the PATCH, POST, or PUT form data.\n\nThis field is only available after ParseForm is called.\n\nThe HTTP client ignores Form and uses Body instead.",
"$ref": "#/$defs/Values"
},
"Header": {
"description": "{@link https://pkg.go.dev/net/http#Request.Header}\n\nA Header represents the key-value pairs in an HTTP header.\n\nThe keys should be in canonical form, as returned by CanonicalHeaderKey.",
"$ref": "#/$defs/Header"
},
"Host": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.Host}\n\nFor server requests, Host specifies the host on which the URL is sought. For HTTP/1 (per RFC 7230, section 5.4), this is either the value of the \"Host\" header or the host name given in the URL itself. For HTTP/2, it is the value of the \":authority\" pseudo-header field.\n\nIt may be of the form \"host:port\". For international domain names, Host may be in Punycode or Unicode form. Use golang.org/x/net/idna to convert it to either format if needed.\n\nTo prevent DNS rebinding attacks, server Handlers should validate that the Host header has a value for which the Handler considers itself authoritative. The included\n\nServeMux supports patterns registered to particular host names and thus protects its registered Handlers.\n\nFor client requests, Host optionally overrides the Host header to send. If empty, the Request.Write method uses the value of URL.Host. Host may contain an international domain name."
},
"Method": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.Method}\n\nMethod specifies the HTTP method (GET, POST, PUT, etc.).\n\nFor client requests, an empty string means GET.\n\nGo's HTTP client does not support sending a request with the CONNECT method. See the documentation on Transport for details."
},
"MultipartForm": {
"description": "{@link https://pkg.go.dev/mime/multipart#Form}\n\nForm is a parsed multipart form.\n\nIts File parts are stored either in memory or on disk,\n\nand are accessible via the *FileHeader's Open method.\n\nIts Value parts are stored as strings.\n\nBoth are keyed by field name.",
"oneOf": [
{
"$ref": "#/$defs/MultipartForm"
},
{
"type": "null"
}
]
},
"PostForm": {
"description": "{@link https://pkg.go.dev/net/http#Request.PostForm}\n\nPostForm contains the parsed form data from PATCH, POST or PUT body parameters.\n\nThis field is only available after ParseForm is called.\n\nThe HTTP client ignores PostForm and uses Body instead.",
"$ref": "#/$defs/Values"
},
"Proto": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.Proto}\n\nThe protocol version for incoming server requests.\n\nFor client requests, these fields are ignored. The HTTP client code always uses either HTTP/1.1 or HTTP/2.\n\nSee the docs on Transport for details."
},
"ProtoMajor": {
"type": "integer",
"description": "{@link https://pkg.go.dev/net/http#Request.ProtoMajor}"
},
"ProtoMinor": {
"type": "integer",
"description": "{@link https://pkg.go.dev/net/http#Request.ProtoMinor}"
},
"Referer": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.RemoteAddr}\n\nReferer returns the referring URL, if sent in the request.\n\nReferer is misspelled as in the request itself, a mistake from the earliest days of HTTP. This value can also be fetched from the Header map as Header[\"Referer\"]; the benefit of making it available as a method is that the compiler can diagnose programs that use the alternate (correct English) spelling req.Referrer() but cannot diagnose programs that use Header[\"Referrer\"]."
},
"RemoteAddr": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.RemoteAddr}\n\nRemoteAddr allows HTTP servers and other software to record the network address that sent the request, usually for logging. This field is not filled in by ReadRequest and has no defined format. The HTTP server in this package sets RemoteAddr to an \"IP:port\" address before invoking a handler.\n\nThis field is ignored by the HTTP client."
},
"TLS": {
"description": "{@link https://pkg.go.dev/net/http#Request.TLS}\n\nTLS allows HTTP servers and other software to record information about the TLS connection on which the request was received. This field is not filled in by ReadRequest.\n\nThe HTTP server in this package sets the field for TLS-enabled connections before invoking a handler; otherwise it leaves the field nil.\n\nThis field is ignored by the HTTP client.",
"oneOf": [
{
"$ref": "#/$defs/TLS"
},
{
"type": "null"
}
]
},
"Trailer": {
"description": "{@link https://pkg.go.dev/net/http#Request.Trailer}\n\nTrailer specifies additional headers that are sent after the request body.\n\nFor server requests, the Trailer map initially contains only the tailer keys, with nil values. (The client declares which trailers it will later send.) While the handler is reading from Body, it must not reference Trailer. After reading from Body returns EOF, Trailer can be read again and will contain non-nil values, if they were sent by the client.\n\nFor client requests, Trailer must be initialized to a map containing the trailer keys to later send. The values may be nil or their final values. The ContentLength must be 0 or -1, to send a chunked request.\n\nAfter the HTTP request is sent the map values can be updated while the request body is read. Once the body returns EOF, the caller must not mutate Trailer.\n\nFew HTTP clients, servers, or proxies support HTTP trailers.",
"oneOf": [
{
"$ref": "#/$defs/Header"
},
{
"type": "null"
}
]
},
"TransferEncoding": {
"type": [
"array",
"null"
],
"description": "{@link https://pkg.go.dev/net/http#Request.TransferEncoding}\n\nTransferEncoding lists the transfer encodings from outermost to innermost. An empty list denotes the \"identity\" encoding.\n\nTransferEncoding can usually be ignored; chunked encoding is automatically added and removed as necessary when sending and receiving requests.",
"items": {
"type": "string"
}
},
"URL": {
"description": "{@link https://pkg.go.dev/net/http#Request.URL}\n\nURL specifies either the URI being requested (for server requests) or the URL to access (for client requests).\n\nFor server requests, the URL is parsed from the URI supplied on the Request-Line as stored in RequestURI. For most requests, fields other than Path and RawQuery will be empty. (See RFC 7230, Section 5.3)\n\nFor client requests, the URL's Host specifies the server to connect to, while the Request's Host field optionally specifies the Host header value to send in the HTTP request.",
"$ref": "#/$defs/RequestURL"
},
"UserAgent": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Request.UserAgent}\n\nUserAgent returns the client's User-Agent, if sent in the request."
}
}
},
"URL": {
"title": "IUrl",
"description": "{@link https://pkg.go.dev/net/http#Request.URL}\n\nURL specifies either the URI being requested (for server requests) or the URL to access (for client requests).\n\nFor server requests, the URL is parsed from the URI supplied on the Request-Line as stored in RequestURI. For most requests, fields other than Path and RawQuery will be empty. (See RFC 7230, Section 5.3)\n\nFor client requests, the URL's Host specifies the server to connect to, while the Request's Host field optionally specifies the Host header value to send in the HTTP request.",
"type": "object",
"additionalProperties": false,
"required": [
"EscapedFragment",
"EscapedPath",
"Hostname",
"IsAbs",
"Port",
"Query",
"Redacted",
"RequestURI",
"String"
],
"properties": {
"EscapedFragment": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.EscapedFragment}\n\nEscapedFragment returns the escaped form of u.Fragment.\n\nIn general there are multiple possible escaped forms of any fragment.\n\nEscapedFragment returns u.RawFragment when it is a valid escaping of u.Fragment.\n\nOtherwise EscapedFragment ignores u.RawFragment and computes an escaped form on its own.\n\nThe String method uses EscapedFragment to construct its result.\n\nIn general, code should call EscapedFragment instead of reading u.RawFragment directly."
},
"EscapedPath": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.EscapedPath}\n\nEscapedPath returns the escaped form of u.Path.\n\nIn general there are multiple possible escaped forms of any path.\n\nEscapedPath returns u.RawPath when it is a valid escaping of u.Path.\n\nOtherwise EscapedPath ignores u.RawPath and computes an escaped form on its own.\n\nThe String and RequestURI methods use EscapedPath to construct their results.\n\nIn general, code should call EscapedPath instead of reading u.RawPath directly."
},
"Hostname": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Hostname}\n\nHostname returns u.Host, stripping any valid port number if present.\n\nIf the result is enclosed in square brackets, as literal IPv6 addresses are, the square brackets are removed from the result."
},
"IsAbs": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/url#URL.IsAbs}\n\nIsAbs reports whether the URL is absolute.\n\nAbsolute means that it has a non-empty scheme."
},
"Port": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Port}\n\nPort returns the port part of u.Host, without the leading colon.\n\nIf u.Host doesn't contain a valid numeric port, Port returns an empty string."
},
"Query": {
"description": "{@link https://pkg.go.dev/net/url#URL.Query}\n\nQuery parses RawQuery and returns the corresponding values.\n\nIt silently discards malformed value pairs.\n\nTo check errors use ParseQuery.",
"$ref": "#/$defs/Values"
},
"Redacted": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Redacted}\n\nRedacted is like String but replaces any password with \"xxxxx\".\n\nOnly the password in u.User is redacted."
},
"RequestURI": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.RequestURI}\n\nRequestURI returns the encoded path?query or opaque?query string that would be used in an HTTP request for u."
},
"String": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.String}\n\nString reassembles the URL into a valid URL string.\n\nThe general form of the result is one of:\n- `scheme:opaque?query#fragment`\n- `scheme://userinfo@host/path?query#fragment`\n\nIf u.Opaque is non-empty, String uses the first form; otherwise it uses the second form.\n\nAny non-ASCII characters in host are escaped.\n\nTo obtain the path, String uses u.EscapedPath().\n\nIn the second form, the following rules apply:\n- if u.Scheme is empty, `scheme:` is omitted.\n- if u.User is nil, `userinfo@` is omitted.\n- if u.Host is empty, `host/` is omitted.\n- if u.Scheme and u.Host are empty and u.User is nil, the entire `scheme://userinfo@host/` is omitted.\n- if u.Host is non-empty and u.Path begins with a /, the form `host/path` does not add its own /.\n- if u.RawQuery is empty, `?query` is omitted.\n- if u.Fragment is empty, `#fragment` is omitted."
}
}
},
"User": {
"title": "IUser",
"description": "Request user",
"type": "object",
"additionalProperties": false,
"required": [
"Password",
"PasswordSet",
"String",
"Username"
],
"properties": {
"Password": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#Userinfo.Password}\n\nPassword returns the password in case it is set."
},
"PasswordSet": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/url#Userinfo.Password}\n\nPassword returns the password whether it is set."
},
"String": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#Userinfo.String}\n\nString returns the encoded userinfo information in the standard form of \"username[:password]\"."
},
"Username": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#Userinfo.Username}\n\nUsername returns the username."
}
}
},
"Param": {
"title": "IParam",
"description": "Param is a single URL parameter, consisting of a key and a value.",
"type": "object",
"additionalProperties": false,
"required": [
"Key",
"Value"
],
"properties": {
"Key": {
"type": "string",
"description": "key name"
},
"Value": {
"type": "string",
"description": "key value"
}
}
},
"Cookie": {
"title": "ICookie",
"description": "{@link https://pkg.go.dev/net/http#Cookie}\n\nA Cookie represents an HTTP cookie as sent in the Set-Cookie header of an HTTP response or the Cookie header of an HTTP request.\n\nSee https://tools.ietf.org/html/rfc6265 for details.",
"type": "object",
"additionalProperties": false,
"required": [
"Name",
"Value",
"Path",
"Domain",
"Expires",
"RawExpires",
"MaxAge",
"Secure",
"HttpOnly",
"SameSite",
"Raw",
"Unparsed"
],
"properties": {
"Name": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Name}\n\nCookie name"
},
"Value": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Value}\n\nCookie value"
},
"Path": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Path}\n\nCookie efficient URL path"
},
"Domain": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Domain}\n\nCookie efficient URL hostname"
},
"Expires": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Expires}\n\nCookie expiration time (ISO 8601)",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-6][0-9]:[0-6][0-9](\\.[0-9]+)?Z$"
},
"RawExpires": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.RawExpires}\n\nfor reading cookies only"
},
"MaxAge": {
"type": "integer",
"description": "{@link https://pkg.go.dev/net/http#Cookie.MaxAge}\n\n- `MaxAge=0` means no 'Max-Age' attribute specified.\n- `MaxAge<0` means delete cookie now, equivalently 'Max-Age: 0'\n- `MaxAge>0` means 'Max-Age' attribute present and given in seconds"
},
"Secure": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Secure}\n\nCookie Secure flag"
},
"HttpOnly": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/http#Cookie.HttpOnly}\n\nCookie HttpOnly flag"
},
"SameSite": {
"type": "integer",
"description": "{@link https://pkg.go.dev/net/http#Cookie.SameSite}\n\nCookie SameSite flag\n\n- `1`: Default mode\n- `2`: Lax mode\n- `3`: Strict mode\n- `4`: None mode",
"enum": [
1,
2,
3,
4
]
},
"Raw": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/http#Cookie.Raw}\n\nRaw text of this cookie"
},
"Unparsed": {
"type": [
"array",
"null"
],
"description": "{@link https://pkg.go.dev/net/http#Cookie.Unparsed}\n\nRaw text of unparsed attribute-value pairs",
"items": {
"type": "string"
}
}
}
},
"Values": {
"title": "IValues",
"description": "{@link https://pkg.go.dev/net/url#Values}\n\nValues maps a string key to a list of values.\n\nIt is typically used for query parameters and form values.\n\nUnlike in the http.Header map, the keys in a Values map are case-sensitive.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"Header": {
"title": "IHeader",
"description": "{@link https://pkg.go.dev/net/http#Request.Header}\n\nHeader contains the request header fields either received by the server or to be sent by the client.\n\nIf a server received a request with header lines,\n```http\nHost: example.com\naccept-encoding: gzip, deflate\nAccept-Language: en-us\nfOO: Bar\nfoo: two\n```\nthen\n```json\n{\n \"Accept-Encoding\": [\"gzip, deflate\"],\n \"Accept-Language\": [\"en-us\"],\n \"Foo\": [\"Bar\", \"two\"],\n}\n```For incoming requests, the Host header is promoted to the Request.Host field and removed from the Header map.\n\nHTTP defines that header names are case-insensitive. The request parser implements this by using CanonicalHeaderKey, making the first character and any characters following a hyphen uppercase and the rest lowercase.\n\nFor client requests, certain headers such as Content-Length and Connection are automatically written when needed and values in Header may be ignored. See the documentation for the Request.Write method.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"MultipartForm": {
"title": "IMultipartForm",
"description": "multipart form data",
"type": "object",
"additionalProperties": false,
"required": [
"Value",
"File"
],
"properties": {
"Value": {
"$ref": "#/$defs/Values"
},
"File": {
"$ref": "#/$defs/MultipartFormFile"
}
}
},
"MultipartFormFile": {
"title": "IMultipartFormFile",
"description": "multipart form file data",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/$defs/File"
}
}
},
"File": {
"title": "IFile",
"description": "multipart form file part",
"type": "object",
"additionalProperties": false,
"required": [
"Content",
"Filename",
"Header",
"Size"
],
"properties": {
"Content": {
"type": "string",
"description": "File data encoded using base64"
},
"Filename": {
"type": "string",
"description": "File name"
},
"Header": {
"description": "{@link https://pkg.go.dev/net/http#Header}\n\nA MIMEHeader represents a MIME-style header mapping keys to sets of values.",
"$ref": "#/$defs/Header"
},
"Size": {
"type": "integer",
"description": "File size (unit: byte)",
"minimum": 0
}
}
},
"RequestURL": {
"title": "IRequestURL",
"description": "{@link https://pkg.go.dev/net/http#Request.URL}\n\nA URL represents a parsed URL (technically, a URI reference).\n\nThe general form represented is:\n\n`[scheme:][//[userinfo@]host][/]path[?query][#fragment]`\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\n`scheme:opaque[?query][#fragment]`\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\n\nA consequence is that it is impossible to tell which slashes in the Path were slashes in the raw URL and which were %2f. This distinction is rarely important, but when it is, the code should use the EscapedPath method, which preserves the original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default encoding of Path is different from the escaped path. See the EscapedPath method for more details.\n\nURL's String method uses the EscapedPath method to obtain the path.",
"type": "object",
"required": [
"Scheme",
"Opaque",
"User",
"Host",
"Path",
"RawPath",
"OmitHost",
"ForceQuery",
"RawQuery",
"Fragment",
"RawFragment"
],
"properties": {
"Scheme": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Scheme}\n\nURL schema"
},
"Opaque": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Opaque}\n\nencoded opaque data"
},
"User": {
"type": "null",
"description": "{@link https://pkg.go.dev/net/url#URL.User}\n\nusername and password information"
},
"Host": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Host}\n\nhost or host:port"
},
"Path": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Path}\n\npath (relative paths may omit leading slash)"
},
"RawPath": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.RawPath}\n\nencoded path hint (see EscapedPath method)"
},
"OmitHost": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/url#URL.OmitHost}\n\ndo not emit empty host (authority)"
},
"ForceQuery": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/net/url#URL.ForceQuery}\n\nappend a query ('?') even if RawQuery is empty"
},
"RawQuery": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.RawQuery}\n\nencoded query values, without '?'"
},
"Fragment": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.Fragment}\n\nfragment for references, without '#'"
},
"RawFragment": {
"type": "string",
"description": "{@link https://pkg.go.dev/net/url#URL.RawFragment}\n\nencoded fragment hint (see EscapedFragment method)"
}
}
},
"TLS": {
"title": "ITLS",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState}\n\nConnectionState records basic TLS details about the connection.",
"type": "object",
"additionalProperties": false,
"required": [
"Version",
"HandshakeComplete",
"DidResume",
"CipherSuite",
"NegotiatedProtocol",
"NegotiatedProtocolIsMutual",
"ServerName",
"PeerCertificates",
"VerifiedChains",
"SignedCertificateTimestamps",
"OCSPResponse",
"TLSUnique"
],
"properties": {
"Version": {
"type": "integer",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.Version}\n\nVersion is the TLS version used by the connection (e.g. VersionTLS12).",
"minimum": 0
},
"HandshakeComplete": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.HandshakeComplete}\n\nHandshakeComplete is true if the handshake has concluded."
},
"DidResume": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.DidResume}\n\nDidResume is true if this connection was successfully resumed from a previous session with a session ticket or similar mechanism."
},
"CipherSuite": {
"type": "integer",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.CipherSuite}\n\nCipherSuite is the cipher suite negotiated for the connection (e.g. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_AES_128_GCM_SHA256).",
"minimum": 0
},
"NegotiatedProtocol": {
"type": "string",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocol}\n\nNegotiatedProtocol is the application protocol negotiated with ALPN."
},
"NegotiatedProtocolIsMutual": {
"type": "boolean",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}\n\nNegotiatedProtocolIsMutual used to indicate a mutual NPN negotiation.\n\nDeprecated: this value is always true."
},
"ServerName": {
"type": "string",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.NegotiatedProtocolIsMutual}\n\nServerName is the value of the Server Name Indication extension sent by the client. It's available both on the server and on the client side."
},
"PeerCertificates": {
"type": "array",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.PeerCertificates}\n\nPeerCertificates are the parsed certificates sent by the peer, in the order in which they were sent. The first element is the leaf certificate that the connection is verified against.\n\nOn the client side, it can't be empty. On the server side, it can be empty if Config.ClientAuth is not RequireAnyClientCert or RequireAndVerifyClientCert.\n\nPeerCertificates and its contents should not be modified.",
"items": {
"$ref": "#/$defs/Certificate"
}
},
"VerifiedChains": {
"type": "array",
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.VerifiedChains}\n\nVerifiedChains is a list of one or more chains where the first element is PeerCertificates[0] and the last element is from Config.RootCAs (on the client side) or Config.ClientCAs (on the server side).\n\nOn the client side, it's set if Config.InsecureSkipVerify is false. On the server side, it's set if Config.ClientAuth is VerifyClientCertIfGiven (and the peer provided a certificate) or RequireAndVerifyClientCert.\n\nVerifiedChains and its contents should not be modified.",
"items": {
"type": "array",
"items": {
"$ref": "#/$defs/Certificate"
}
}
},
"SignedCertificateTimestamps": {
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.SignedCertificateTimestamps}\n\nSignedCertificateTimestamps is a list of SCTs provided by the peer through the TLS handshake for the leaf certificate, if any."
},
"OCSPResponse": {
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.OCSPResponse}\n\nOCSPResponse is a stapled Online Certificate Status Protocol (OCSP) response provided by the peer for the leaf certificate, if any."
},
"TLSUnique": {
"description": "{@link https://pkg.go.dev/crypto/tls#ConnectionState.TLSUnique}\n\nTLSUnique contains the \"tls-unique\" channel binding value (see RFC 5929, Section 3).\nThis value will be nil for TLS 1.3 connections and for resumed connections that don't support Extended Master Secret (RFC 7627)."
}
}
},
"Certificate": {
"title": "ICertificate",
"description": "{@link https://pkg.go.dev/crypto/x509#Certificate}\n\nA Certificate represents an X.509 certificate.",
"type": "object",
"required": [
"Raw",
"RawTBSCertificate",
"RawSubjectPublicKeyInfo",
"RawSubject",
"RawIssuer",
"Signature",
"SignatureAlgorithm",
"PublicKeyAlgorithm",
"PublicKey",
"Version",
"SerialNumber",
"Issuer",
"Subject",
"NotBefore",
"KeyUsage",
"Extensions",
"ExtraExtensions",
"UnhandledCriticalExtensions",
"ExtKeyUsage",
"UnknownExtKeyUsage",
"BasicConstraintsValid",
"IsCA",
"MaxPathLen",
"MaxPathLenZero",
"SubjectKeyId",
"AuthorityKeyId",
"OCSPServer",
"IssuingCertificateURL",
"DNSNames",
"EmailAddresses",
"IPAddresses",
"URIs",
"PermittedDNSDomainsCritical",
"PermittedDNSDomains",
"ExcludedDNSDomains",
"PermittedIPRanges",
"ExcludedIPRanges",
"PermittedEmailAddresses",
"ExcludedEmailAddresses",
"PermittedURIDomains",
"ExcludedURIDomains",
"CRLDistributionPoints",
"PolicyIdentifiers"
]
}
}
}
forwardProxy
- 🔥 前置代理
/api/network/forwardProxy
请求
ts
/**
* Forward proxy
*/
export interface IPayload {
/**
* Content-Type for request body
* @defaultValue "application/json"
*/
readonly contentType?: string;
/**
* request headers list
*/
readonly headers: { [key: string]: string }[];
/**
* HTTP method to request
* @defaultValue "GET"
*/
readonly method?: TRequestMethod;
/**
* request body
*/
readonly payload?: Payload;
/**
* Encoding schema for request payload
* @defaultValue "text"
*/
readonly payloadEncoding?: TEncodeSchema;
/**
* Encoding schema for response body
* @defaultValue "text"
*/
readonly responseEncoding?: TEncodeSchema;
/**
* timeout to request (ms)
* @defaultValue 7000
*/
readonly timeout?: number;
/**
* URL to request
*/
readonly url: string;
}
/**
* HTTP method to request
* @defaultValue "GET"
*/
export type TRequestMethod = "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE";
/**
* request body
*/
export type Payload = { [key: string]: any } | string;
/**
* Encoding schema for request payload
* @defaultValue "text"
*
* Encoding schema for response body
* @defaultValue "text"
*/
export type TEncodeSchema = "base32-hex" | "base32-std" | "base32" | "base64-std" | "base64-url" | "base64" | "hex" | "text";
json5
/**
* schemas/kernel/api/network/forwardProxy/payload.schema.json5
* 正向代理
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#Forward-proxy
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.3/kernel/api/network.go#L36-L200
* @pathname: /api/network/forwardProxy
* @version: 2.10.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/forwardProxy/payload.schema.json5',
$comment: 'v2.10.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Forward proxy',
type: 'object',
additionalProperties: false,
required: [
'url',
'headers',
],
properties: {
url: {
// 请求 URL
type: 'string',
description: 'URL to request',
format: 'uri',
},
method: {
// HTTP 请求方法
title: 'TRequestMethod',
type: 'string',
description: 'HTTP method to request\n@defaultValue "GET"',
enum: [
'GET',
'HEAD',
'POST',
'PUT',
'PATCH',
'DELETE',
'OPTIONS',
'TRACE',
'CONNECT',
],
default: 'GET',
},
timeout: {
// 请求超时时间 (单位: ms)
type: 'integer',
description: 'timeout to request (ms)\n@defaultValue 7000',
minimum: 0,
default: 7000,
},
contentType: {
// 请求体内容类型
type: 'string',
description: 'Content-Type for request body\n@defaultValue "application/json"',
default: 'application/json',
},
headers: {
// 请求头
type: 'array',
description: 'request headers list',
items: {
$ref: '#/$defs/headers',
},
},
payload: {
// 请求体
type: [
'object',
'string',
],
description: 'request body',
},
payloadEncoding: {
// 请求体编码类型
description: 'Encoding schema for request payload\n@defaultValue "text"',
$ref: '#/$defs/encodeSchema',
},
responseEncoding: {
// 响应体编码类型
description: 'Encoding schema for response body\n@defaultValue "text"',
$ref: '#/$defs/encodeSchema',
},
},
},
headers: {
title: 'IHeaders',
description: 'Request headers',
type: 'object',
additionalProperties: {
type: 'string',
},
},
encodeSchema: {
title: 'TEncodeSchema',
type: 'string',
default: 'text',
enum: [
'text',
'base64',
'base64-std',
'base64-url',
'base32',
'base32-std',
'base32-hex',
'hex',
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/forwardProxy/payload.schema.json",
"$comment": "v2.10.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Forward proxy",
"type": "object",
"additionalProperties": false,
"required": [
"url",
"headers"
],
"properties": {
"url": {
"type": "string",
"description": "URL to request",
"format": "uri"
},
"method": {
"title": "TRequestMethod",
"type": "string",
"description": "HTTP method to request\n@defaultValue \"GET\"",
"enum": [
"GET",
"HEAD",
"POST",
"PUT",
"PATCH",
"DELETE",
"OPTIONS",
"TRACE",
"CONNECT"
],
"default": "GET"
},
"timeout": {
"type": "integer",
"description": "timeout to request (ms)\n@defaultValue 7000",
"minimum": 0,
"default": 7000
},
"contentType": {
"type": "string",
"description": "Content-Type for request body\n@defaultValue \"application/json\"",
"default": "application/json"
},
"headers": {
"type": "array",
"description": "request headers list",
"items": {
"$ref": "#/$defs/headers"
}
},
"payload": {
"type": [
"object",
"string"
],
"description": "request body"
},
"payloadEncoding": {
"description": "Encoding schema for request payload\n@defaultValue \"text\"",
"$ref": "#/$defs/encodeSchema"
},
"responseEncoding": {
"description": "Encoding schema for response body\n@defaultValue \"text\"",
"$ref": "#/$defs/encodeSchema"
}
}
},
"headers": {
"title": "IHeaders",
"description": "Request headers",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"encodeSchema": {
"title": "TEncodeSchema",
"type": "string",
"default": "text",
"enum": [
"text",
"base64",
"base64-std",
"base64-url",
"base32",
"base32-std",
"base32-hex",
"hex"
]
}
}
}
响应
ts
/**
* Forward proxy
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
/**
* response body
*/
readonly body: string;
/**
* response body encoding schema
*/
readonly bodyEncoding: TEncodeSchema;
/**
* response content-type
*/
readonly contentType: string;
/**
* response elapsed
*/
readonly elapsed: number;
/**
* response headers
*/
readonly headers: { [key: string]: string[] };
/**
* HTTP status code
*/
readonly status: number;
/**
* URL to request
*/
readonly url: string;
}
/**
* response body encoding schema
*/
export type TEncodeSchema = "base32-hex" | "base32-std" | "base32" | "base64-std" | "base64-url" | "base64" | "hex" | "text";
json5
/**
* schemas/kernel/api/network/forwardProxy/response.schema.json5
* 正向代理
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#Forward-proxy
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.3/kernel/api/network.go#L36-L200
* @pathname: /api/network/forwardProxy
* @version: 2.10.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/forwardProxy/response.schema.json5',
$comment: 'v2.10.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Forward proxy',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'url',
'status',
'elapsed',
'contentType',
'headers',
'body',
'bodyEncoding',
],
properties: {
url: {
// 请求 URL
type: 'string',
description: 'URL to request',
format: 'uri',
},
status: {
// HTTP 状态码
type: 'integer',
description: 'HTTP status code',
minimum: 100,
maximum: 599,
},
elapsed: {
// 响应用时
type: 'integer',
description: 'response elapsed',
minimum: 0,
},
contentType: {
// 响应体内容类型
type: 'string',
description: 'response content-type',
},
headers: {
// 响应头
description: 'response headers',
$ref: '#/$defs/headers',
},
body: {
// 响应体内容
type: 'string',
description: 'response body',
},
bodyEncoding: {
// 响应体内容所使用的编码方案
title: 'TEncodeSchema',
type: 'string',
description: 'response body encoding schema',
default: 'text',
enum: [
'text',
'base64',
'base64-std',
'base64-url',
'base32',
'base32-std',
'base32-hex',
'hex',
],
},
},
},
headers: {
title: 'IHeaders',
description: 'Response headers',
type: 'object',
additionalProperties: {
type: 'array',
items: {
type: 'string',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/network/forwardProxy/response.schema.json",
"$comment": "v2.10.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Forward proxy",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"url",
"status",
"elapsed",
"contentType",
"headers",
"body",
"bodyEncoding"
],
"properties": {
"url": {
"type": "string",
"description": "URL to request",
"format": "uri"
},
"status": {
"type": "integer",
"description": "HTTP status code",
"minimum": 100,
"maximum": 599
},
"elapsed": {
"type": "integer",
"description": "response elapsed",
"minimum": 0
},
"contentType": {
"type": "string",
"description": "response content-type"
},
"headers": {
"description": "response headers",
"$ref": "#/$defs/headers"
},
"body": {
"type": "string",
"description": "response body"
},
"bodyEncoding": {
"title": "TEncodeSchema",
"type": "string",
"description": "response body encoding schema",
"default": "text",
"enum": [
"text",
"base64",
"base64-std",
"base64-url",
"base32",
"base32-std",
"base32-hex",
"hex"
]
}
}
},
"headers": {
"title": "IHeaders",
"description": "Response headers",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}