budget-go/web/controller/file/controller.go
2024-09-25 11:21:23 +02:00

29 lines
504 B
Go

package file
import (
"github.com/labstack/echo/v4"
"gitnet.fr/deblan/budget/config"
"gitnet.fr/deblan/budget/database/model"
f "gitnet.fr/deblan/budget/file"
)
type Controller struct {
}
func New(e *echo.Echo) *Controller {
c := Controller{}
e.GET("/api/files", c.Files)
return &c
}
func (ctrl *Controller) Files(c echo.Context) error {
if nil == model.LoadSessionUser(c) {
return c.Redirect(302, "/login")
}
tree := f.GetTree("", config.Get().File.Path)
return c.JSON(200, tree)
}