Documentation
¶
Overview ¶
Package resthandler evaluates and execute REST requests to the remote server.
Index ¶
- Constants
- func NewRESTfulHandler(operation *highv3.Operation, rawProxyAction *yaml.Node, ...) (proxyhandler.ProxyHandler, error)
- type ProxyCustomRESTfulResponseConfig
- type ProxyRESTfulActionConfig
- type ProxyRESTfulParameter
- type ProxyRESTfulParameterConfig
- type ProxyRESTfulRequestConfig
- type RESTfulHandler
- func (re *RESTfulHandler) Handle(ctx context.Context, request *proxyhandler.Request, ...) (*http.Response, any, error)
- func (re *RESTfulHandler) Stream(ctx context.Context, request *proxyhandler.Request, writer http.ResponseWriter, ...) (*http.Response, error)
- func (*RESTfulHandler) Type() proxyhandler.ProxyActionType
Constants ¶
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 ¶
func (re *RESTfulHandler) Handle( ctx context.Context, request *proxyhandler.Request, options *proxyhandler.ProxyHandleOptions, ) (*http.Response, any, error)
Handle resolves the HTTP request and proxies that request to the remote server.
func (*RESTfulHandler) Stream ¶
func (re *RESTfulHandler) Stream( ctx context.Context, request *proxyhandler.Request, writer http.ResponseWriter, options *proxyhandler.ProxyHandleOptions, ) (*http.Response, error)
Stream resolves the HTTP request and proxies that request to the remote server. The response is a stream.
func (*RESTfulHandler) Type ¶
func (*RESTfulHandler) Type() proxyhandler.ProxyActionType
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. |