44 lines
752 B
Go
44 lines
752 B
Go
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.trj.tw/golang/go-file-serve/module/context"
|
|
"git.trj.tw/golang/go-file-serve/routes/api"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// NewEngine -
|
|
func NewEngine() *gin.Engine {
|
|
engine := gin.New()
|
|
engine.Use(gin.Logger())
|
|
engine.Use(gin.Recovery())
|
|
|
|
return engine
|
|
}
|
|
|
|
// SetRoutes -
|
|
func SetRoutes(r *gin.Engine) {
|
|
r.GET("/", func(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"message": "success",
|
|
})
|
|
})
|
|
|
|
apiGroup := r.Group("/api")
|
|
{
|
|
apiGroup.GET("/files", context.PatchContext(api.GetFileList))
|
|
}
|
|
|
|
viewGroup := r.Group("/v")
|
|
{
|
|
viewGroup.GET("*path", context.PatchContext(FSList))
|
|
}
|
|
dlGroup := r.Group("/dl")
|
|
{
|
|
dlGroup.GET("*path", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{})
|
|
})
|
|
}
|
|
}
|