feat: add error handling

This commit is contained in:
Louis Dalibard 2024-04-27 13:58:01 +02:00
parent b3e1b4f212
commit 8e4943d5ae

View File

@ -3,6 +3,7 @@ package route
import ( import (
"leech/config" "leech/config"
"leech/html" "leech/html"
"net/url"
"os" "os"
"path" "path"
"sort" "sort"
@ -12,7 +13,11 @@ import (
) )
func HandleList(c *fiber.Ctx) error { func HandleList(c *fiber.Ctx) error {
req := c.Params("req") encodedReq := c.Params("req")
req, err := url.QueryUnescape(encodedReq)
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString(err.Error())
}
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML) c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
if req == "" { if req == "" {
keys := make([]string, 0, len(config.Config.ServeDirs)) keys := make([]string, 0, len(config.Config.ServeDirs))