resthandler

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: 28 Imported by: 0

Documentation

Overview

Package resthandler evaluates and execute REST requests to the remote server.

Index

Constants

View Source
const ProxyActionTypeREST proxyhandler.ProxyActionType = "rest"

ProxyActionTypeREST represents a constant value for REST proxy action.

Variables

This section is empty.

Functions

func NewRESTfulHandler

func NewRESTfulHandler(
	operation *highv3.Operation,
	rawProxyAction *yaml.Node,
	options *proxyhandler.NewProxyHandlerOptions,
) (proxyhandler.ProxyHandler, error)

NewRESTfulHandler creates a RESTHandler from operation.

Types

type ProxyCustomRESTfulResponseConfig

type ProxyCustomRESTfulResponseConfig struct {
	// Content type of the response to be transformed to.
	ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
	// Configurations for transforming response data.
	Body *gotransform.TemplateTransformerConfig `json:"body,omitempty" yaml:"body,omitempty"`
}

ProxyCustomRESTfulResponseConfig represents configurations for the proxy response.

func (ProxyCustomRESTfulResponseConfig) IsZero

func (conf ProxyCustomRESTfulResponseConfig) IsZero() bool

IsZero checks if the configuration is empty.

type ProxyRESTfulActionConfig

type ProxyRESTfulActionConfig struct {
	// Type of the proxy action which is always rest.
	Type proxyhandler.ProxyActionType `json:"type" yaml:"type" jsonschema:"enum=rest"`
	// Configurations for the REST proxy request.
	Request *ProxyRESTfulRequestConfig `json:"request,omitempty" yaml:"request,omitempty"`
	// Configurations for evaluating REST responses.
	Response *ProxyCustomRESTfulResponseConfig `json:"response,omitempty" yaml:"response,omitempty"`
}

ProxyRESTfulActionConfig represents a proxy action config for REST operation.

type ProxyRESTfulParameter

type ProxyRESTfulParameter struct {
	jmes.FieldMappingEntry
	parameter.BaseParameter
}

ProxyRESTfulParameter represents an object of evaluated configurations for a parameter.

type ProxyRESTfulParameterConfig

type ProxyRESTfulParameterConfig struct {
	jmes.FieldMappingEntryConfig `yaml:",inline"`
	parameter.BaseParameter      `yaml:",inline"`
}

ProxyRESTfulParameterConfig represents an object of transformation configurations for a parameter.

type ProxyRESTfulRequestConfig

type ProxyRESTfulRequestConfig struct {
	// Overrides the request URL. Use the original request path if empty.
	URL string `json:"url,omitempty" yaml:"url,omitempty"`
	// Overrides the request method. Use the original request method if empty.
	Method string `json:"method,omitempty" jsonschema:"enum=GET,enum=POST,enum=PATCH,enum=PUT,enum=DELETE" yaml:"method,omitempty"`
	// The configuration to transform query, path, header and cookie parameters.
	Parameters []ProxyRESTfulParameterConfig `json:"parameters,omitempty" yaml:"parameters" jsonschema:"nullable"`
	// Content type of the body to be transformed to.
	ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
	// The configuration to transform request body.
	Body *gotransform.TemplateTransformerConfig `json:"body,omitempty" yaml:"body"`
	// If this is true, all query parameters will be forwarded.
	// The default value is true if there is no query parameter is configured.
	ForwardAllQueryParams *bool `json:"forwardAllQueryParams,omitempty" yaml:"forwardAllQueryParams"`
}

ProxyRESTfulRequestConfig represents configurations for the proxy request.

func (ProxyRESTfulRequestConfig) IsZero

func (rr ProxyRESTfulRequestConfig) IsZero() bool

IsZero checks if the configuration is empty.

type RESTfulHandler

type RESTfulHandler struct {
	// contains filtered or unexported fields
}

RESTfulHandler implements the ProxyHandler interface for RESTful proxy.

func (*RESTfulHandler) Handle

Handle resolves the HTTP request and proxies that request to the remote server.

func (*RESTfulHandler) Stream

Stream resolves the HTTP request and proxies that request to the remote server. The response is a stream.

func (*RESTfulHandler) Type

Type returns type of the current handler.

Directories

Path Synopsis
Package contenttype implement encoders and decoders for data by content types.
Package contenttype implement encoders and decoders for data by content types.
Package parameter defines serialization functions for HTTP parameters.
Package parameter defines serialization functions for HTTP parameters.

Jump to

Keyboard shortcuts

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