proxyhandler

package
v0.0.0-...-8c81104 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

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 *oaschema.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
	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 ProxyActionType

type ProxyActionType string

ProxyActionType represents enums of proxy types.

type ProxyHandleOptions

type ProxyHandleOptions struct {
	NewRequest NewRequestFunc
	Settings   *oaschema.OpenAPIResourceSettings
}

ProxyHandleOptions hold request options for the proxy handler.

func (*ProxyHandleOptions) ForwardResponseHeaders

func (pho *ProxyHandleOptions) ForwardResponseHeaders(
	writer http.ResponseWriter,
	response *http.Response,
)

ForwardResponseHeaders forward headers from http.Response to http.ResponseWriter.

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

func NewRequest(method string, uri *url.URL, headers http.Header, body any) *Request

NewRequest creates a new Request instance.

func (*Request) Body

func (r *Request) Body() any

Body returns the body of the request.

func (*Request) Header

func (r *Request) Header() http.Header

Header returns the headers of the request.

func (*Request) Method

func (r *Request) Method() string

Method returns the method of the request.

func (*Request) Path

func (r *Request) Path() string

Path returns the request path of the request.

func (*Request) Query

func (r *Request) Query() url.Values

Query returns query parameter values of the request URL.

func (*Request) QueryParams

func (r *Request) QueryParams() map[string]any

QueryParams returns query parameter values of the request URL.

func (*Request) SetBody

func (r *Request) SetBody(value any)

SetBody sets the body of the request.

func (*Request) SetCookieParams

func (r *Request) SetCookieParams(values map[string]any)

SetCookieParams sets decoded cookie parameters for the request.

func (*Request) SetHeaderParams

func (r *Request) SetHeaderParams(values map[string]any)

SetHeaderParams sets decoded header parameters for the request.

func (*Request) SetMethod

func (r *Request) SetMethod(method string)

SetMethod sets a new method to the request.

func (*Request) SetPath

func (r *Request) SetPath(value string)

SetPath sets the URL path to the request.

func (*Request) SetQuery

func (r *Request) SetQuery(values url.Values)

SetQuery sets query parameters for the request.

func (*Request) SetQueryParams

func (r *Request) SetQueryParams(values map[string]any)

SetQueryParams sets query parameters for the request.

func (*Request) SetURLParams

func (r *Request) SetURLParams(value map[string]any)

SetURLParams sets the URL parameters of the request.

func (*Request) ToMap

func (r *Request) ToMap() map[string]any

ToMap converts the struct to map.

func (*Request) URL

func (r *Request) URL() string

URL returns the URL string of the request.

func (*Request) URLParams

func (r *Request) URLParams() map[string]any

URLParams returns parameter values of the request URL.

Jump to

Keyboard shortcuts

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