Skip to content

Commit

Permalink
refactor: remove redundant uploadHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuxas committed Oct 15, 2024
1 parent ba7ebb6 commit b36457d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions abyss.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
7 changes: 0 additions & 7 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b36457d

Please sign in to comment.