From b36457dc455de18f1ea5b2262241502fba0eb8bf Mon Sep 17 00:00:00 2001 From: jabuxas Date: Tue, 15 Oct 2024 18:27:24 -0300 Subject: [PATCH] refactor: remove redundant uploadHandler --- abyss.go | 4 ++-- handlers.go | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/abyss.go b/abyss.go index b968ca9..3a349de 100644 --- a/abyss.go +++ b/abyss.go @@ -68,10 +68,10 @@ func main() { ) mux.HandleFunc("/last", app.lastUploadedHandler) if auth == "yes" { - mux.HandleFunc("/upload", app.basicAuth(app.uploadHandler)) + mux.HandleFunc("/upload", app.basicAuth(app.parserHandler)) slog.Warn("text uploading through the browser will be restricted") } else { - mux.HandleFunc("/upload", app.uploadHandler) + mux.HandleFunc("/upload", app.parserHandler) slog.Warn("text uploading through the browser will NOT be restricted") } diff --git a/handlers.go b/handlers.go index 487533f..80dd328 100644 --- a/handlers.go +++ b/handlers.go @@ -134,13 +134,6 @@ func (app *Application) lastUploadedHandler(w http.ResponseWriter, r *http.Reque http.ServeFile(w, r, app.lastUploadedFile) } -func (app *Application) uploadHandler(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodPost { - app.parserHandler(w, r) - return - } -} - func (app *Application) parserHandler(w http.ResponseWriter, r *http.Request) { if _, err := os.Stat(app.filesDir); err != nil { if err := os.Mkdir(app.filesDir, 0750); err != nil {