Files
OpenList/server/router.go

34 lines
718 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
public := app.Group("/api/public")
{
// TODO check accounts
2021-10-28 12:37:31 +08:00
public.Post("/path", CheckAccount, Path)
2021-10-27 22:45:36 +08:00
public.Get("/settings", GetSettingsPublic)
2021-10-26 22:28:37 +08:00
}
admin := app.Group("/api/admin")
{
2021-10-27 22:45:36 +08:00
admin.Use(Auth)
2021-10-26 22:28:37 +08:00
admin.Get("/settings", GetSettingsByType)
admin.Post("/settings", SaveSettings)
admin.Post("/account", SaveAccount)
admin.Get("/accounts", GetAccounts)
admin.Delete("/account", DeleteAccount)
admin.Get("/drivers", GetDrivers)
}
}