This commit is contained in:
Lain Iwakura 2025-07-12 19:06:38 +03:00
parent 71735c02aa
commit f5c177c19e
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8

29
main.go
View File

@ -209,26 +209,31 @@ func main() {
wg.Add(1) wg.Add(1)
go func(p string) { go func(p string) {
defer wg.Done() defer wg.Done()
mux := http.NewServeMux()
mux.HandleFunc("/", handler)
mux.HandleFunc("/ws", wsHandler)
mux.HandleFunc("/status", statusHandler)
server := &http.Server{ server := &http.Server{
Addr: ":" + p, Addr: ":" + p,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "Apache/2.4.41 (Ubuntu)") w.Header().Set("Server", "0BSD_FOR_EVERYONE")
w.Header().Set("X-Powered-By", "PHP/7.4.3") w.Header().Set("X-Powered-By", "0BSD_FOR_EVERYONE")
if r.Method == "GET" && r.URL.Path == "/" {
handler(w, r)
return
}
if r.URL.Path == "/ws" {
wsHandler(w, r)
return
}
if r.URL.Path == "/status" {
statusHandler(w, r)
return
}
defer func() {
if r := recover(); r != nil {
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(404) w.WriteHeader(404)
w.Write([]byte("<html><body><h1>Not Found</h1></body></html>")) w.Write([]byte("<html><body><h1>Not Found</h1></body></html>"))
}
}()
mux.ServeHTTP(w, r)
}), }),
ReadTimeout: 30 * time.Second, ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second,