added default hook handler arg name and router search helper

This commit is contained in:
Gani Georgiev
2024-10-13 13:25:04 +03:00
parent 3e0869a30b
commit ff3f4332ce
4 changed files with 12 additions and 2 deletions
+5
View File
@@ -137,6 +137,11 @@ func (group *RouterGroup[T]) GET(path string, action func(T) error) *Route[T] {
return group.Route(http.MethodGet, path, action)
}
// SEARCH is a shorthand for [Group.AddRoute] with SEARCH as route method.
func (group *RouterGroup[T]) SEARCH(path string, action func(T) error) *Route[T] {
return group.Route("SEARCH", path, action)
}
// POST is a shorthand for [Group.AddRoute] with POST as route method.
func (group *RouterGroup[T]) POST(path string, action func(T) error) *Route[T] {
return group.Route(http.MethodPost, path, action)
+5
View File
@@ -260,6 +260,11 @@ func TestRouterGroupRouteAliases(t *testing.T) {
http.MethodGet,
"/test",
},
{
group.SEARCH("/test", testAction),
"SEARCH",
"/test",
},
{
group.POST("/test", testAction),
http.MethodPost,