mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 19:31:27 +00:00
add support for HTTP OPTIONS
This commit is contained in:
parent
5bf4593498
commit
4a2c7e6789
3 changed files with 9 additions and 1 deletions
|
@ -316,6 +316,7 @@ Operations perform an action on a resource using an HTTP method verb. The follow
|
|||
- Put
|
||||
- Patch
|
||||
- Delete
|
||||
- Options
|
||||
|
||||
Operations can take dependencies, parameters, & request bodies and produce response headers and responses. These are each discussed in more detail below.
|
||||
|
||||
|
|
|
@ -188,3 +188,8 @@ func (r *Resource) Patch(docs string, handler interface{}) {
|
|||
func (r *Resource) Delete(docs string, handler interface{}) {
|
||||
r.operation(http.MethodDelete, docs, handler)
|
||||
}
|
||||
|
||||
// Options creates an HTTP OPTIONS operation on the resource.
|
||||
func (r *Resource) Options(docs string, handler interface{}) {
|
||||
r.operation(http.MethodOptions, docs, handler)
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ func TestResourceWithAddedParam(t *testing.T) {
|
|||
}
|
||||
|
||||
var resourceFuncsTest = []string{
|
||||
"Head", "List", "Get", "Post", "Put", "Patch", "Delete",
|
||||
"Head", "List", "Get", "Post", "Put", "Patch", "Delete", "Options",
|
||||
}
|
||||
|
||||
func TestResourceFuncs(outer *testing.T) {
|
||||
|
@ -156,6 +156,8 @@ func TestResourceFuncs(outer *testing.T) {
|
|||
f = res.Patch
|
||||
case "Delete":
|
||||
f = res.Delete
|
||||
case "Options":
|
||||
f = res.Options
|
||||
default:
|
||||
panic("invalid case " + local)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue