DriveLinked/router/router.go

28 lines
636 B
Go
Raw Normal View History

2022-04-03 12:30:50 +08:00
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) {
2022-04-05 18:16:20 +08:00
// 需要登录
users.Use(middleware.SignRequired)
2022-04-03 12:30:50 +08:00
// 用户详细信息
users.Get("/profile/{name:string}", controller.UserProfile)
users.Post("/profile", controller.UserProfile)
})
return app
}