alist/server/router.go

43 lines
987 B
Go
Raw Normal View History

2021-10-26 22:28:37 +08:00
package server
2021-10-28 12:37:31 +08:00
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
)
2021-10-26 22:28:37 +08:00
func InitApiRouter(app *fiber.App) {
2021-10-28 12:37:31 +08:00
// TODO from settings
app.Use(cors.New())
2021-10-26 22:28:37 +08:00
app.Get("/d/*", Down)
2021-10-29 00:02:02 +08:00
// TODO check allow proxy?
app.Get("/p/*", Proxy)
2021-10-26 22:28:37 +08:00
2021-10-30 00:35:29 +08:00
api := app.Group("/api")
api.Use(SetSuccess)
public := api.Group("/public")
2021-10-26 22:28:37 +08:00
{
2021-10-28 12:37:31 +08:00
public.Post("/path", CheckAccount, Path)
2021-10-31 21:27:47 +08:00
public.Post("/preview", CheckAccount, Preview)
2021-10-27 22:45:36 +08:00
public.Get("/settings", GetSettingsPublic)
2021-10-31 00:36:17 +08:00
public.Post("/link", CheckAccount, Link)
2021-10-26 22:28:37 +08:00
}
2021-10-30 00:35:29 +08:00
admin := api.Group("/admin")
2021-10-26 22:28:37 +08:00
{
2021-10-27 22:45:36 +08:00
admin.Use(Auth)
2021-10-30 00:35:29 +08:00
admin.Get("/login", Login)
admin.Get("/settings", GetSettings)
2021-10-26 22:28:37 +08:00
admin.Post("/settings", SaveSettings)
admin.Post("/account", SaveAccount)
admin.Get("/accounts", GetAccounts)
admin.Delete("/account", DeleteAccount)
admin.Get("/drivers", GetDrivers)
2021-11-01 22:42:24 +08:00
admin.Get("/clear_cache",ClearCache)
2021-11-02 19:25:54 +08:00
admin.Get("/metas", GetMetas)
admin.Post("/meta", SaveMeta)
admin.Delete("/meta", DeleteMeta)
2021-10-26 22:28:37 +08:00
}
}