Modify: use lowercase route name

pull/247/head
HFO4 5 years ago
parent 5991fd66ce
commit 89b54e401c

@ -1 +1 @@
Subproject commit fa3e709238dcecf85320949cd9413b37b48177f1
Subproject commit 341a70e7c8d451fa8c627786434cb5f617fd2f26

@ -35,37 +35,37 @@ func InitRouter() *gin.Engine {
/*
*/
v3 := r.Group("/Api/V3")
v3 := r.Group("/api/v3")
{
// 测试用路由
v3.GET("Site/Ping", controllers.Ping)
v3.GET("site/ping", controllers.Ping)
// 用户登录
v3.POST("User/Session", controllers.UserLogin)
v3.POST("user/session", controllers.UserLogin)
// 验证码
v3.GET("Captcha", controllers.Captcha)
v3.GET("captcha", controllers.Captcha)
// 站点全局配置
v3.GET("Site/Config", controllers.SiteConfig)
v3.GET("site/config", controllers.SiteConfig)
// 需要登录保护的
auth := v3.Group("")
auth.Use(middleware.AuthRequired())
{
// 用户
user := auth.Group("User")
user := auth.Group("user")
{
// 当前登录用户信息
user.GET("Me", controllers.UserMe)
user.GET("me", controllers.UserMe)
}
// 文件
file := auth.Group("File")
file := auth.Group("file")
{
// 文件上传
file.POST("Upload", controllers.FileUploadStream)
file.POST("upload", controllers.FileUploadStream)
}
// 目录
directory := auth.Group("Directory")
directory := auth.Group("directory")
{
// 文件上传
directory.PUT("", controllers.Ping)

@ -21,7 +21,7 @@ func TestPing(t *testing.T) {
router := InitRouter()
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/Api/V3/Site/Ping", nil)
req, _ := http.NewRequest("GET", "/api/v3/site/ping", nil)
router.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
@ -35,7 +35,7 @@ func TestCaptcha(t *testing.T) {
req, _ := http.NewRequest(
"GET",
"/Api/V3/Captcha",
"/api/v3/captcha",
nil,
)
@ -146,7 +146,7 @@ func TestUserSession(t *testing.T) {
}
req, _ := http.NewRequest(
"POST",
"/Api/V3/User/Session",
"/api/v3/user/session",
bytes.NewReader([]byte(testCase.reqBody)),
)
router.ServeHTTP(w, req)
@ -199,7 +199,7 @@ func TestSessionAuthCheck(t *testing.T) {
for _, testCase := range testCases {
req, _ := http.NewRequest(
"GET",
"/Api/V3/User/Me",
"/api/v3/user/me",
nil,
)
if testCase.userRows != nil {
@ -227,7 +227,7 @@ func TestSiteConfigRoute(t *testing.T) {
req, _ := http.NewRequest(
"GET",
"/Api/V3/Site/Config",
"/api/v3/site/config",
nil,
)
router.ServeHTTP(w, req)
@ -245,7 +245,7 @@ func TestSiteConfigRoute(t *testing.T) {
req, _ = http.NewRequest(
"GET",
"/Api/V3/Site/Config",
"/api/v3/site/config",
nil,
)
router.ServeHTTP(w, req)

Loading…
Cancel
Save