webhookd/pkg/api/types.go
Nicolas Carlier 6b3623f67a feat(api): refactore router
- Simplify router
- Single routes onfiguration file
- Improve HTTP logger
2021-07-11 13:09:44 +02:00

30 lines
616 B
Go

package api
import (
"net/http"
"github.com/ncarlier/webhookd/pkg/config"
"github.com/ncarlier/webhookd/pkg/middleware"
)
// HandlerFunc custom function handler
type HandlerFunc func(conf *config.Config) http.Handler
// Route is the structure of an HTTP route definition
type Route struct {
Path string
HandlerFunc HandlerFunc
Middlewares middleware.Middlewares
}
// Routes is a list of Route
type Routes []Route
func route(path string, handler HandlerFunc, middlewares ...middleware.Middleware) Route {
return Route{
Path: path,
HandlerFunc: handler,
Middlewares: middlewares,
}
}