From 9d9acbe7d345cf6d49ddb26cc9d4a3c09fa64550 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sun, 3 Mar 2024 11:24:30 +0100 Subject: [PATCH] Print file names when curling /files/ path. --- main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.go b/main.go index 73241ac..af75509 100644 --- a/main.go +++ b/main.go @@ -122,6 +122,23 @@ func Files(c echo.Context) error { log.Fatal(err) } + UserAgent := c.Request().UserAgent() + + log.Print(UserAgent) + + match, err := regexp.MatchString("^curl/.*", UserAgent) + if err != nil { + log.Fatal(err) + } + + if match { + out := "" + for _, f := range filelist { + out += f.Name() + "\n" + } + return c.String(http.StatusOK, out) + } + var Type string var Content string