框架基本搭建完成
This commit is contained in:
25
router/router.go
Normal file
25
router/router.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user