proxyhandler

package
v0.0.0-...-ad9b89a Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 18 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 *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 ProxyActionType

type ProxyActionType string

ProxyActionType represents enums of proxy types.

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

func NewRequest(method string, uri *url.URL, header 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) GetURL

func (r *Request) GetURL() *url.URL

GetURL returns the URL 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) SetBody

func (r *Request) SetBody(value any)

SetBody sets the body of the request.

func (*Request) SetMethod

func (r *Request) SetMethod(method string)

SetMethod sets a new method to the request.

func (*Request) SetURL

func (r *Request) SetURL(u *url.URL)

SetURL sets the URL to the request.

func (*Request) URL

func (r *Request) URL() string

URL returns the URL string of the request.

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.

Jump to

Keyboard shortcuts

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