/*
 * @description: 路由配置
 * @Author: CP
 * @Date: 2020-08-23 21:32:54
 * @FilePath: \construction_management\web\routes\routes.go
 */
package routes

import (
	"github.com/kataras/iris/v12/mvc"
	"go.mod/bootstrap"
	"go.mod/services"
	"go.mod/web/controllers"
	"go.mod/web/middleware"
)

// func NewCsrf() iris.Handler {
// 	protect1 := csrf.Protect([]byte("9AB0F421E53A477C084477AEA06096F5"))
// 	csrf.Secure(false)
// 	return protect1
// }

func Configure(b *bootstrap.Bootstrapper) {
	//service加载
	ProjectAccountService := services.NewProjectAccountService()
	NewLoginService := services.NewLoginService()
	//CSRF相关
	b.Use(middleware.SetCsrf)

	//b.Party("/", protect)
	//protect := NewCsrf()

	//登录相关
	//login := mvc.New(b.Party("/", protect))
	login := mvc.New(b.Party("/"))
	login.Register(ProjectAccountService)
	login.Register(NewLoginService)
	login.Handle(new(controllers.LoginController))

	//项目用户相关
	//account := mvc.New(b.Party("/account"))
	//account.Router.Use(middleware.BasicAuth)
	// account.Register(ManagerService)
	// account.Handle(new(controllers.AccountController))

}
