refactor: remove redundant uploadHandler

This commit is contained in:
jabuxas 2024-10-15 18:27:24 -03:00
parent ba7ebb6210
commit 00d2f3e510

View File

@ -75,7 +75,7 @@ func (app *Application) fileListingHandler(w http.ResponseWriter, r *http.Reques
func (app *Application) indexHandler(w http.ResponseWriter, r *http.Request) { func (app *Application) indexHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost { if r.Method == http.MethodPost {
app.parserHandler(w, r) app.uploadHandler(w, r)
return return
} }
@ -135,13 +135,6 @@ func (app *Application) lastUploadedHandler(w http.ResponseWriter, r *http.Reque
} }
func (app *Application) uploadHandler(w http.ResponseWriter, r *http.Request) { 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.Stat(app.filesDir); err != nil {
if err := os.Mkdir(app.filesDir, 0750); err != nil { if err := os.Mkdir(app.filesDir, 0750); err != nil {
http.Error(w, "Error creating storage directory", http.StatusInternalServerError) http.Error(w, "Error creating storage directory", http.StatusInternalServerError)