Documentation
¶
Overview ¶
Package openapiclient implements a client to proxy requests to external services.
Index ¶
- Variables
- func BuildMetadataTree(document *highv3.Document, getEnv goenvconf.GetEnvFunc) (*internal.Node, error)
- type ClientOption
- func AllowTraceRequestHeaders(keys []string) ClientOption
- func AllowTraceResponseHeaders(keys []string) ClientOption
- func EnableClientTrace(enabled bool) ClientOption
- func WithAuthenticator(authenticator authscheme.HTTPClientAuthenticator) ClientOption
- func WithClientOptions(options *gohttpc.ClientOptions) ClientOption
- func WithCustomAttributesFunc(fn gohttpc.CustomAttributesFunc) ClientOption
- func WithGetEnvFunc(getter goenvconf.GetEnvFunc) ClientOption
- func WithHTTPClient(httpClient *http.Client) ClientOption
- func WithMetricHighCardinalityPath(enabled bool) ClientOption
- func WithRetry(retry retrypolicy.RetryPolicy[*http.Response]) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- func WithTraceHighCardinalityPath(enabled bool) ClientOption
- func WithUserAgent(userAgent string) ClientOption
- type ProxyClient
- func (pc *ProxyClient) Close() error
- func (pc *ProxyClient) Execute(ctx context.Context, method string, requestPath string, header http.Header, ...) (*http.Response, any, error)
- func (pc *ProxyClient) ServeHTTP(writer http.ResponseWriter, request *http.Request)
- func (pc *ProxyClient) Settings() *oaschema.OpenAPIResourceSettings
- func (pc *ProxyClient) Stream(ctx context.Context, writer http.ResponseWriter, request *proxyhandler.Request) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BuildMetadataTree ¶
func BuildMetadataTree( document *highv3.Document, getEnv goenvconf.GetEnvFunc, ) (*internal.Node, error)
BuildMetadataTree builds the metadata tree from the API document.
Types ¶
type ClientOption ¶
type ClientOption func(*clientOptions)
ClientOption abstracts a function to modify proxy client options.
func AllowTraceRequestHeaders ¶
func AllowTraceRequestHeaders(keys []string) ClientOption
AllowTraceRequestHeaders creates an option to set allowed headers for tracing.
func AllowTraceResponseHeaders ¶
func AllowTraceResponseHeaders(keys []string) ClientOption
AllowTraceResponseHeaders creates an option to set allowed headers for tracing.
func EnableClientTrace ¶
func EnableClientTrace(enabled bool) ClientOption
EnableClientTrace creates an option to enable the HTTP client trace.
func WithAuthenticator ¶
func WithAuthenticator(authenticator authscheme.HTTPClientAuthenticator) ClientOption
WithAuthenticator creates an option to set the default authenticator.
func WithClientOptions ¶
func WithClientOptions(options *gohttpc.ClientOptions) ClientOption
WithClientOptions create an option to set the client options of gohttpc client.
func WithCustomAttributesFunc ¶
func WithCustomAttributesFunc(fn gohttpc.CustomAttributesFunc) ClientOption
WithCustomAttributesFunc sets the function to add custom attributes to spans and metrics.
func WithGetEnvFunc ¶
func WithGetEnvFunc(getter goenvconf.GetEnvFunc) ClientOption
WithGetEnvFunc returns a function to set the GetEnvFunc getter to [HTTPClientAuthenticatorOptions].
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient create an option to set the HTTP client.
func WithMetricHighCardinalityPath ¶
func WithMetricHighCardinalityPath(enabled bool) ClientOption
WithMetricHighCardinalityPath enables high cardinality path on metrics.
func WithRetry ¶
func WithRetry(retry retrypolicy.RetryPolicy[*http.Response]) ClientOption
WithRetry creates an option to set the default retry policy.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout creates an option to set the default timeout.
func WithTraceHighCardinalityPath ¶
func WithTraceHighCardinalityPath(enabled bool) ClientOption
WithTraceHighCardinalityPath enables high cardinality path on traces.
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOption
WithUserAgent creates an option to set the user agent.
type ProxyClient ¶
type ProxyClient struct {
// contains filtered or unexported fields
}
ProxyClient helps manage and execute REST and GraphQL APIs from the API document.
func NewProxyClient ¶
func NewProxyClient( ctx context.Context, metadata *oaschema.OpenAPIResourceDefinition, options ...ClientOption, ) (*ProxyClient, error)
NewProxyClient creates a proxy client from the API document.
func (*ProxyClient) Close ¶
func (pc *ProxyClient) Close() error
Close method performs cleanup and closure activities on the client instance.
func (*ProxyClient) Execute ¶
func (pc *ProxyClient) Execute( ctx context.Context, method string, requestPath string, header http.Header, body any, ) (*http.Response, any, error)
Execute routes and proxies the request to the remote server.
func (*ProxyClient) ServeHTTP ¶
func (pc *ProxyClient) ServeHTTP( writer http.ResponseWriter, request *http.Request, )
func (*ProxyClient) Settings ¶
func (pc *ProxyClient) Settings() *oaschema.OpenAPIResourceSettings
Settings returns the inner settings of the resource.
func (*ProxyClient) Stream ¶
func (pc *ProxyClient) Stream( ctx context.Context, writer http.ResponseWriter, request *proxyhandler.Request, ) (*http.Response, error)
Stream routes the request to the remote server. The response will be transformed and written into the stream.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package handler defines the global proxy handler with default constructors
|
Package handler defines the global proxy handler with default constructors |
|
graphqlhandler
Package graphqlhandler evaluates and execute GraphQL requests to the remote server.
|
Package graphqlhandler evaluates and execute GraphQL requests to the remote server. |
|
proxyhandler
Package proxyhandler defines types for the proxy handler.
|
Package proxyhandler defines types for the proxy handler. |
|
resthandler
Package resthandler evaluates and execute REST requests to the remote server.
|
Package resthandler evaluates and execute REST requests to the remote server. |
|
Package internal implements internal functionality for the proxy client.
|
Package internal implements internal functionality for the proxy client. |