package router import ( "drive-linked/pkg/controller" "drive-linked/pkg/middleware" "github.com/kataras/iris/v12" ) func Router() *iris.Application { app := iris.New() // 注册全局中间件 // 允许所有跨域请求 (目前开发阶段仅供调试,正式环境不应使用) app.UseGlobal(middleware.AllowAllCORS) // 注册路由 // v1 v1 := app.Party("/v1") v1.PartyFunc("/users", func(users iris.Party) { // 用户详细信息 users.Get("/profile/{name:string}", controller.UserProfile) users.Post("/profile", controller.UserProfile) }) return app }