refactor: remove redundant uploadHandler
This commit is contained in:
parent
ba7ebb6210
commit
b36457dc45
4
abyss.go
4
abyss.go
@ -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")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user