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