refactor: remove redundant uploadHandler

This commit is contained in:
jabuxas 2024-10-15 18:27:24 -03:00
parent ba7ebb6210
commit b36457dc45
2 changed files with 2 additions and 9 deletions

View File

@ -68,10 +68,10 @@ func main() {
) )
mux.HandleFunc("/last", app.lastUploadedHandler) mux.HandleFunc("/last", app.lastUploadedHandler)
if auth == "yes" { 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") slog.Warn("text uploading through the browser will be restricted")
} else { } else {
mux.HandleFunc("/upload", app.uploadHandler) mux.HandleFunc("/upload", app.parserHandler)
slog.Warn("text uploading through the browser will NOT be restricted") slog.Warn("text uploading through the browser will NOT be restricted")
} }

View File

@ -134,13 +134,6 @@ func (app *Application) lastUploadedHandler(w http.ResponseWriter, r *http.Reque
http.ServeFile(w, r, app.lastUploadedFile) 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) { func (app *Application) parserHandler(w http.ResponseWriter, r *http.Request) {
if _, err := os.Stat(app.filesDir); err != nil { if _, err := os.Stat(app.filesDir); err != nil {
if err := os.Mkdir(app.filesDir, 0750); err != nil { if err := os.Mkdir(app.filesDir, 0750); err != nil {