Documentation
¶
Overview ¶
Package proxyhandler defines types for the proxy handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyCredentials ¶
type APIKeyCredentials struct {
APIKey *goenvconf.EnvString `json:"apiKey,omitempty" yaml:"apiKey,omitempty"`
}
APIKeyCredentials holds apiKey credentials of the security scheme.
type BasicCredentials ¶
type BasicCredentials struct {
Username *goenvconf.EnvString `json:"username,omitempty" yaml:"username,omitempty"`
Password *goenvconf.EnvString `json:"password,omitempty" yaml:"password,omitempty"`
}
BasicCredentials holds basic credentials of the security scheme.
type InsertRouteOptions ¶
type InsertRouteOptions struct {
GetEnv goenvconf.GetEnvFunc
}
InsertRouteOptions represents options for inserting routes.
type NewProxyHandlerFunc ¶
type NewProxyHandlerFunc func(operation *highv3.Operation, rawProxyAction *yaml.Node, options *NewProxyHandlerOptions) (ProxyHandler, error)
NewProxyHandlerFunc abstracts a function to create a new proxy handler.
type NewProxyHandlerOptions ¶
type NewProxyHandlerOptions struct {
Method string
Parameters []*highv3.Parameter
GetEnv goenvconf.GetEnvFunc
}
NewProxyHandlerOptions hold request options for the proxy handler.
func (NewProxyHandlerOptions) GetEnvFunc ¶
func (nrp NewProxyHandlerOptions) GetEnvFunc() goenvconf.GetEnvFunc
GetEnvFunc returns a function to get environment variables.
type NewRequestFunc ¶
type NewRequestFunc func(method string, uri string) *gohttpc.RequestWithClient
NewRequestFunc abstracts a function to create an HTTP request.
type OAuth2Credentials ¶
type OAuth2Credentials struct {
ClientID *goenvconf.EnvString `json:"clientId,omitempty" yaml:"clientId,omitempty"`
ClientSecret *goenvconf.EnvString `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
// Optional query parameters for the token and refresh URLs.
EndpointParams map[string]goenvconf.EnvString `json:"endpointParams,omitempty" yaml:"endpointParams,omitempty"`
}
OAuth2Credentials holds OAuth2 credentials of the security scheme.
type OpenAPIAuthenticator ¶
type OpenAPIAuthenticator struct {
// contains filtered or unexported fields
}
OpenAPIAuthenticator manages security schemes from the openapi document.
func NewOpenAPIv3Authenticator ¶
func NewOpenAPIv3Authenticator( document *highv3.Document, getEnv goenvconf.GetEnvFunc, ) (*OpenAPIAuthenticator, error)
NewOpenAPIv3Authenticator an authenticator from an OpenAPI v3 document.
func (*OpenAPIAuthenticator) GetAuthenticator ¶
func (oaa *OpenAPIAuthenticator) GetAuthenticator( security []*base.SecurityRequirement, ) authscheme.HTTPClientAuthenticator
GetAuthenticator finds a suitable authenticator by security requirements.
type ProxyHandleOptions ¶
type ProxyHandleOptions struct {
NewRequest NewRequestFunc
Settings *oaschema.OpenAPIResourceSettings
ParamValues map[string]string
}
ProxyHandleOptions hold request options for the proxy handler.
type ProxyHandler ¶
type ProxyHandler interface {
// Type returns type of the current handler.
Type() ProxyActionType
// Handle resolves the HTTP request and proxies that request to the remote server.
// The response is decoded to a native Go type.
Handle(
ctx context.Context,
request *Request,
options *ProxyHandleOptions,
) (*http.Response, any, error)
// Stream resolves the HTTP request and proxies that request to the remote server.
// The response body can be a raw stream or transformed reader.
Stream(
ctx context.Context,
request *Request,
writer http.ResponseWriter,
options *ProxyHandleOptions,
) (*http.Response, error)
}
ProxyHandler abstracts the executor to proxy HTTP requests.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request to be proxying.
func NewRequest ¶
NewRequest creates a new Request instance.
type RequestTemplateData ¶
type RequestTemplateData struct {
Params map[string]string
QueryParams url.Values
Headers map[string]string
Body any
}
RequestTemplateData represents the request data for template transformation.
func NewRequestTemplateData ¶
func NewRequestTemplateData( request *Request, paramValues map[string]string, ) *RequestTemplateData
NewRequestTemplateData creates a new RequestTemplateData from the HTTP request to a map for request transformation.
func (RequestTemplateData) ToMap ¶
func (rtd RequestTemplateData) ToMap() map[string]any
ToMap converts the struct to map.