From 71a6ebaf4303ee0aea1ec4d22566864ca80398c4 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Tue, 2 Aug 2022 22:16:58 +0800 Subject: [PATCH] chore: dev test --- server/dev.go | 15 +++++++++++++++ server/router.go | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 server/dev.go diff --git a/server/dev.go b/server/dev.go new file mode 100644 index 00000000..ea923af2 --- /dev/null +++ b/server/dev.go @@ -0,0 +1,15 @@ +package server + +import ( + "github.com/alist-org/alist/v3/server/middlewares" + "github.com/gin-gonic/gin" +) + +func dev(g *gin.RouterGroup) { + g.GET("/path/*path", middlewares.Down, func(ctx *gin.Context) { + rawPath := ctx.MustGet("path").(string) + ctx.JSON(200, gin.H{ + "path": rawPath, + }) + }) +} diff --git a/server/router.go b/server/router.go index 0398710e..068bd9dd 100644 --- a/server/router.go +++ b/server/router.go @@ -1,6 +1,7 @@ package server import ( + "github.com/alist-org/alist/v3/cmd/args" "github.com/alist-org/alist/v3/internal/conf" "github.com/alist-org/alist/v3/internal/message" "github.com/alist-org/alist/v3/server/common" @@ -31,6 +32,9 @@ func Init(r *gin.Engine) { fs(auth.Group("/fs")) admin(auth.Group("/admin", middlewares.AuthAdmin)) + if args.Dev { + dev(r.Group("/dev")) + } } func admin(g *gin.RouterGroup) {