1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-11-13 00:34:17 +02:00
parent 7b6a8f1e26
commit c81b97188a
7 changed files with 101 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
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))
}
}