feat: modularize the code.

This commit is contained in:
CronyAkatsuki 2025-11-07 18:16:45 +01:00
parent 6f4757a1e9
commit a59c892087
7 changed files with 293 additions and 243 deletions

22
delete.go Normal file
View file

@ -0,0 +1,22 @@
package main
import (
"github.com/labstack/echo/v4"
"net/http"
"os"
)
func Delete(c echo.Context) error {
file := c.Param("file")
filePath := "files/" + file
if _, err := os.Stat(filePath); err != nil {
return c.String(http.StatusOK, "That file doesn't exist on the server\n")
}
err := os.Remove(filePath)
if err != nil {
return c.String(http.StatusOK, "Error while deleting "+file+"\n")
}
return c.String(http.StatusOK, "Deleted file from server: "+file+"\n")
}