-
Notifications
You must be signed in to change notification settings - Fork 6
Endpoint Traits
This wiki contains a mapping between Smithy Endpoint traits and generated Ruby code.
Configures a custom operation endpoint. This trait has a required hostPrefix
property. This trait is supported with Hearth
middleware to augment the endpoint. The middleware will take the input params, the host prefix property from the @endpoint
trait, and a configuration flag for disabling host prefix behavior.
@readonly
@endpoint(hostPrefix: "data.")
operation GetStatus {
input: GetStatusInput,
output: GetStatusOutput
}
The generated code is:
# client.rb in get_status operation
stack.use(
Hearth::Middleware::HostPrefix,
prefix: "data.",
disable_host_prefix: options.fetch(:disable_host_prefix, @disable_host_prefix)
)
The request will have data.
prefixed to the host URL. Note: the hostPrefix is applied to the Endpoint resolved by the Endpoints#endpoint-provider
Binds a top-level operation input structure member to a label in the hostPrefix
of an endpoint trait. In Hearth::Middleware::HostPrefix
, the middleware evaluates the host prefix, determines that a label is needed for foo
, and then check the params for such a key. If the key doesn’t exist or is empty, an ArgumentError
is raised.
@readonly
@endpoint(hostPrefix: "{foo}.data.")
operation GetStatus {
input: GetStatusInput,
output: GetStatusOutput
}
structure GetStatusInput {
@required
@hostLabel
foo: String
}
If input[:foo] = ‘bar’
then the request will have bar.data.
prefixed to the host URL.