add support for HTTP OPTIONS

This commit is contained in:
David Weiser 2020-06-15 08:40:38 -07:00
parent 5bf4593498
commit 4a2c7e6789
3 changed files with 9 additions and 1 deletions

View file

@ -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.

View file

@ -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)
}

View file

@ -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)
}