mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
24 lines
670 B
Go
24 lines
670 B
Go
package api
|
|
|
|
import (
|
|
"myapp/domain/repository"
|
|
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
// NewRouter accepts some dependencies
|
|
// and returns a function which returns the routes on the given Iris Party (group of routes).
|
|
func NewRouter(userRepo repository.UserRepository, todoRepo repository.TodoRepository) func(iris.Party) {
|
|
return func(router iris.Party) {
|
|
router.Post("/signin", SignIn(userRepo))
|
|
|
|
router.Use(Verify()) // protect the next routes with JWT.
|
|
|
|
router.Post("/todos", CreateTodo(todoRepo))
|
|
router.Get("/todos", ListTodos(todoRepo))
|
|
router.Get("/todos/{id}", GetTodo(todoRepo))
|
|
|
|
router.Get("/admin/todos", AllowAdmin, ListAllTodos(todoRepo))
|
|
}
|
|
}
|