support multiple http methods

This commit is contained in:
Eyal Post 2017-06-05 18:19:45 +03:00
parent 46fc9d75ae
commit 0099ef2f92
1 changed files with 17 additions and 15 deletions

View File

@ -707,7 +707,8 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error {
controllerList[pkgpath+controllerName] = make(map[string]*swagger.Item)
item = &swagger.Item{}
}
switch HTTPMethod {
for _, hm := range strings.Split(HTTPMethod, ",") {
switch hm {
case "GET":
item.Get = &opts
case "POST":
@ -723,6 +724,7 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error {
case "OPTIONS":
item.Options = &opts
}
}
controllerList[pkgpath+controllerName][routerPath] = item
}
return nil