Replace shell-based downloader execution with validated arguments, enforce request hardening and safer defaults, and refactor handlers/router/state so job control is safer and easier to maintain.
20 lines
604 B
Go
20 lines
604 B
Go
package main
|
|
|
|
import "net/http"
|
|
|
|
func newRouter() http.Handler {
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/", handleRoot)
|
|
mux.HandleFunc("/upload", handleUpload)
|
|
mux.HandleFunc("/select", handleSelect)
|
|
mux.HandleFunc("/process", handleProcess)
|
|
mux.HandleFunc("/progress", handleProgress)
|
|
mux.HandleFunc("/abort", handleAbort)
|
|
mux.HandleFunc("/pause", handlePause)
|
|
mux.HandleFunc("/resume", handleResume)
|
|
mux.HandleFunc("/clear-completed", handleClearCompleted)
|
|
mux.HandleFunc("/ws", handleWebSocket)
|
|
mux.HandleFunc("/set-speed-limit", handleSetSpeedLimit)
|
|
return withSecurityHeaders(mux)
|
|
}
|