fixed comments and added default generic arg name

This commit is contained in:
Gani Georgiev
2024-10-14 14:32:52 +03:00
parent 56b756e16b
commit 47d5ea3ce2
8 changed files with 41 additions and 31 deletions

View File

@@ -5,7 +5,7 @@ import "github.com/pocketbase/pocketbase/tools/hook"
type Route[T hook.Resolver] struct {
excludedMiddlewares map[string]struct{}
Action func(T) error
Action func(e T) error
Method string
Path string
Middlewares []*hook.Handler[T]
@@ -17,8 +17,8 @@ type Route[T hook.Resolver] struct {
// aka. executes in the order they were registered.
//
// If you need to specify a named middleware (ex. so that it can be removed)
// or middleware with custom exec prirority, use the [Bind] method.
func (route *Route[T]) BindFunc(middlewareFuncs ...func(T) error) *Route[T] {
// or middleware with custom exec prirority, use the [Route.Bind] method.
func (route *Route[T]) BindFunc(middlewareFuncs ...func(e T) error) *Route[T] {
for _, m := range middlewareFuncs {
route.Middlewares = append(route.Middlewares, &hook.Handler[T]{Func: m})
}