You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I define two separate traits, each with a required header, such as:
Trait("version_required”, func() {
Headers(func() {
Header("X-Api-Version", String,
"API Version, must be specified",
func() { Enum("2017-05-21", "latest") })
Required("X-Api-Version")
})
})
Trait("etag_required", func() {
Headers(func() {
Header("Etag", UUID,
"ETag is part of http standard, and is used for detecting resource conflicts")
Required("Etag")
})
})
Only the one mentioned first("version_required” in this case) will be required. The subsequent ones will be validated for data type if sent, but not required.
The same is true for headers added directly to the action.
Action("show", func() {
UseTrait("etag_required")
Headers(func() {
Header("X-Api-Version", String,
"API Version, must be specified either using this header or a query string param",
func() { Enum("2017-05-21", "latest") })
Required("X-Api-Version")
})
Routing(
GET(…
Etag will be required, but X-Api-Version will not be.
If I require all headers in the same Trait or Headers definition, it does work as expected and requires them all.
The text was updated successfully, but these errors were encountered:
If I define two separate traits, each with a required header, such as:
Then use them both on an action,
Only the one mentioned first("version_required” in this case) will be required. The subsequent ones will be validated for data type if sent, but not required.
The same is true for headers added directly to the action.
Etag will be required, but X-Api-Version will not be.
If I require all headers in the same Trait or Headers definition, it does work as expected and requires them all.
The text was updated successfully, but these errors were encountered: