mirror of https://github.com/Xhofe/alist
36 lines
755 B
Go
36 lines
755 B
Go
package server
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
|
)
|
|
|
|
func InitApiRouter(app *fiber.App) {
|
|
|
|
// TODO from settings
|
|
app.Use(cors.New())
|
|
app.Get("/d/*", Down)
|
|
// TODO check allow proxy?
|
|
app.Get("/p/*", Proxy)
|
|
|
|
api := app.Group("/api")
|
|
api.Use(SetSuccess)
|
|
public := api.Group("/public")
|
|
{
|
|
public.Post("/path", CheckAccount, Path)
|
|
public.Get("/settings", GetSettingsPublic)
|
|
}
|
|
|
|
admin := api.Group("/admin")
|
|
{
|
|
admin.Use(Auth)
|
|
admin.Get("/login", Login)
|
|
admin.Get("/settings", GetSettings)
|
|
admin.Post("/settings", SaveSettings)
|
|
admin.Post("/account", SaveAccount)
|
|
admin.Get("/accounts", GetAccounts)
|
|
admin.Delete("/account", DeleteAccount)
|
|
admin.Get("/drivers", GetDrivers)
|
|
}
|
|
}
|