Documentation ¶
Overview ¶
Package rest is a generated protocol buffer package.
It is generated from these files:
spec.proto
It has these top-level messages:
RouteExtension Parameters TransformationSpec
Index ¶
- Constants
- func EncodeFunctionSpec(spec TransformationSpec) *types.Struct
- func EncodeRouteExtension(spec RouteExtension) *types.Struct
- type Parameters
- func (*Parameters) Descriptor() ([]byte, []int)
- func (this *Parameters) Equal(that interface{}) bool
- func (m *Parameters) GetHeaders() map[string]string
- func (m *Parameters) GetPath() *google_protobuf1.StringValue
- func (*Parameters) ProtoMessage()
- func (m *Parameters) Reset()
- func (m *Parameters) String() string
- type Plugin
- func (p *Plugin) HttpFilters(_ *plugins.HttpFilterPluginParams) []plugins.StagedHttpFilter
- func (p *Plugin) Init(options bootstrap.Options) error
- func (p *Plugin) ProcessRoute(pluginParams *plugins.RoutePluginParams, in *v1.Route, out *envoyroute.Route) error
- func (p *Plugin) ProcessUpstream(params *plugins.UpstreamPluginParams, in *v1.Upstream, out *envoyapi.Cluster) error
- type RouteExtension
- func (*RouteExtension) Descriptor() ([]byte, []int)
- func (this *RouteExtension) Equal(that interface{}) bool
- func (m *RouteExtension) GetParameters() *Parameters
- func (m *RouteExtension) GetResponseParams() *Parameters
- func (m *RouteExtension) GetResponseTransformation() *TransformationSpec
- func (*RouteExtension) ProtoMessage()
- func (m *RouteExtension) Reset()
- func (m *RouteExtension) String() string
- type TransformationSpec
- func (*TransformationSpec) Descriptor() ([]byte, []int)
- func (this *TransformationSpec) Equal(that interface{}) bool
- func (m *TransformationSpec) GetBody() *google_protobuf1.StringValue
- func (m *TransformationSpec) GetHeaders() map[string]string
- func (m *TransformationSpec) GetPath() string
- func (*TransformationSpec) ProtoMessage()
- func (m *TransformationSpec) Reset()
- func (m *TransformationSpec) String() string
Constants ¶
const (
ServiceTypeREST = "REST"
)
Variables ¶
This section is empty.
Functions ¶
func EncodeFunctionSpec ¶
func EncodeFunctionSpec(spec TransformationSpec) *types.Struct
func EncodeRouteExtension ¶
func EncodeRouteExtension(spec RouteExtension) *types.Struct
Types ¶
type Parameters ¶
type Parameters struct { // headers that will be used to extract data for processing output templates // Gloo will search for parameters by their name in header value strings, enclosed in single // curly braces // Example: // extensions: // parameters: // headers: // x-user-id: { userId } Headers map[string]string `` /* 148-byte string literal not displayed */ // part of the (or the entire) path that will be used extract data for processing output templates // Gloo will search for parameters by their name in header value strings, enclosed in single // curly braces // Example: // extensions: // parameters: // path: /users/{ userId } Path *google_protobuf1.StringValue `protobuf:"bytes,2,opt,name=path" json:"path,omitempty"` }
Parameters define a set of parameters for REST Transformations Parameters can be extracted from HTTP Headers and Request Path Parameters can also be extracted from the HTTP Body, provided that it is valid JSON-encoded Gloo will search for parameters by their name in strings, enclosed in single curly braces, and attempt to match them to the variables in REST Function Templates for example:
# route match: {...} destination: {...} extensions: parameters: headers: x-user-id: { userId } --- # function name: myfunc spec: body: | { "id": {{ userId }} }
func (*Parameters) Descriptor ¶ added in v0.4.2
func (*Parameters) Descriptor() ([]byte, []int)
func (*Parameters) Equal ¶ added in v0.4.2
func (this *Parameters) Equal(that interface{}) bool
func (*Parameters) GetHeaders ¶ added in v0.4.2
func (m *Parameters) GetHeaders() map[string]string
func (*Parameters) GetPath ¶ added in v0.4.2
func (m *Parameters) GetPath() *google_protobuf1.StringValue
func (*Parameters) ProtoMessage ¶ added in v0.4.2
func (*Parameters) ProtoMessage()
func (*Parameters) Reset ¶ added in v0.4.2
func (m *Parameters) Reset()
func (*Parameters) String ¶ added in v0.4.2
func (m *Parameters) String() string
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) HttpFilters ¶
func (p *Plugin) HttpFilters(_ *plugins.HttpFilterPluginParams) []plugins.StagedHttpFilter
func (*Plugin) ProcessRoute ¶
func (p *Plugin) ProcessRoute(pluginParams *plugins.RoutePluginParams, in *v1.Route, out *envoyroute.Route) error
func (*Plugin) ProcessUpstream ¶
type RouteExtension ¶
type RouteExtension struct { // If specified, these parameters will be used as inputs for REST templates for // the destination function for the route // (if the route destination is a functional destination that has a REST transformation) Parameters *Parameters `protobuf:"bytes,1,opt,name=parameters" json:"parameters,omitempty"` // If specified, responses on this route will be transformed according to the template(s) provided // in the transformation spec here ResponseTransformation *TransformationSpec `protobuf:"bytes,2,opt,name=response_transformation,json=responseTransformation" json:"response_transformation,omitempty"` // If specified, paremeters for the response transformation will be extracted from these sources ResponseParams *Parameters `protobuf:"bytes,3,opt,name=response_params,json=responseParams" json:"response_params,omitempty"` }
The REST Route Extension contains two components: * parameters for calling REST functions * Response Transformation
func DecodeRouteExtension ¶
func DecodeRouteExtension(generic *types.Struct) (RouteExtension, error)
func (*RouteExtension) Descriptor ¶ added in v0.4.2
func (*RouteExtension) Descriptor() ([]byte, []int)
func (*RouteExtension) Equal ¶ added in v0.4.2
func (this *RouteExtension) Equal(that interface{}) bool
func (*RouteExtension) GetParameters ¶ added in v0.4.2
func (m *RouteExtension) GetParameters() *Parameters
func (*RouteExtension) GetResponseParams ¶ added in v0.4.2
func (m *RouteExtension) GetResponseParams() *Parameters
func (*RouteExtension) GetResponseTransformation ¶ added in v0.4.2
func (m *RouteExtension) GetResponseTransformation() *TransformationSpec
func (*RouteExtension) ProtoMessage ¶ added in v0.4.2
func (*RouteExtension) ProtoMessage()
func (*RouteExtension) Reset ¶ added in v0.4.2
func (m *RouteExtension) Reset()
func (*RouteExtension) String ¶ added in v0.4.2
func (m *RouteExtension) String() string
type TransformationSpec ¶ added in v0.4.2
type TransformationSpec struct { // a Jinja-style Template string for the outbound request path. Only useful for request transformation Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // a map of keys to Jinja-style Template strings HTTP Headers. Useful for request and response transformations Headers map[string]string `` /* 148-byte string literal not displayed */ // a Jinja-style Template string for the outbound HTTP Body. Useful for request and response transformations // If this is nil, the body will be passed through unmodified. If set to an empty string, the body will be removed // from the HTTP message. Body *google_protobuf1.StringValue `protobuf:"bytes,3,opt,name=body" json:"body,omitempty"` }
TransformationSpec can act as part of a Route Extension (as a Response Transformation), or as a FunctionSpec (as a Request Transformation). Use TransformationSpec as the Function Spec for REST Services (where `Upstream.ServiceInfo.Type == "REST"`) TransformationSpec contains a set of templates that will be used to modify the Path, Headers, and Body Parameters for the tempalte come from the following sources: path: HTTP Request path (if present) method: HTTP Request method (if present) parameters specified in the RouteExtension.Parameters (or, in the case of ResponseTransformation, RouteExtension.ResponseParams) Parameters can also be extracted from the Request / Response Body provided that they are JSON To do so, specify the field using JSONPath syntax any field from the request body, assuming it's json (http://goessner.net/articles/JsonPath/index.html#e2) Note: REST Service detection and configuration can be performed automatically by Gloo for services that implement Swagger and serve their `swagger.json` file on a common endpoint (e.g. /v1/swagger.json). Custom endpoints for swagger.json can be added via the Function Discovery configuration. Requires Function Discovery to be enabled.
func DecodeFunctionSpec ¶
func DecodeFunctionSpec(generic *types.Struct) (TransformationSpec, error)
func (*TransformationSpec) Descriptor ¶ added in v0.4.2
func (*TransformationSpec) Descriptor() ([]byte, []int)
func (*TransformationSpec) Equal ¶ added in v0.4.2
func (this *TransformationSpec) Equal(that interface{}) bool
func (*TransformationSpec) GetBody ¶ added in v0.4.2
func (m *TransformationSpec) GetBody() *google_protobuf1.StringValue
func (*TransformationSpec) GetHeaders ¶ added in v0.4.2
func (m *TransformationSpec) GetHeaders() map[string]string
func (*TransformationSpec) GetPath ¶ added in v0.4.2
func (m *TransformationSpec) GetPath() string
func (*TransformationSpec) ProtoMessage ¶ added in v0.4.2
func (*TransformationSpec) ProtoMessage()
func (*TransformationSpec) Reset ¶ added in v0.4.2
func (m *TransformationSpec) Reset()
func (*TransformationSpec) String ¶ added in v0.4.2
func (m *TransformationSpec) String() string