migration

This commit is contained in:
Zeni Kim 2024-09-15 19:19:54 -05:00
parent ac8ba89865
commit c6006861cb
6 changed files with 100 additions and 100 deletions

View file

@ -6,10 +6,10 @@
package core
type Route struct {
Method string
Path string
Controller Controller
Middlewares []Middleware
Method string
Path string
Controller Controller
Hooks []Hook
}
type Router struct {
@ -29,72 +29,72 @@ func ResolveRouter() *Router {
return router
}
func (r *Router) Get(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Get(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: GET,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: GET,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Post(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Post(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: POST,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: POST,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Delete(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Delete(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: DELETE,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: DELETE,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Patch(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Patch(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: PATCH,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: PATCH,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Put(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Put(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: PUT,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: PUT,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Options(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Options(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: OPTIONS,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: OPTIONS,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}
func (r *Router) Head(path string, controller Controller, middlewares ...Middleware) *Router {
func (r *Router) Head(path string, controller Controller, hooks ...Hook) *Router {
r.Routes = append(r.Routes, Route{
Method: HEAD,
Path: path,
Controller: controller,
Middlewares: middlewares,
Method: HEAD,
Path: path,
Controller: controller,
Hooks: hooks,
})
return r
}