update
This commit is contained in:
parent
71735c02aa
commit
f5c177c19e
33
main.go
33
main.go
@ -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")
|
||||||
|
|
||||||
defer func() {
|
if r.Method == "GET" && r.URL.Path == "/" {
|
||||||
if r := recover(); r != nil {
|
handler(w, r)
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
return
|
||||||
w.WriteHeader(404)
|
}
|
||||||
w.Write([]byte("<html><body><h1>Not Found</h1></body></html>"))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
mux.ServeHTTP(w, r)
|
if r.URL.Path == "/ws" {
|
||||||
|
wsHandler(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.URL.Path == "/status" {
|
||||||
|
statusHandler(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
w.WriteHeader(404)
|
||||||
|
w.Write([]byte("<html><body><h1>Not Found</h1></body></html>"))
|
||||||
}),
|
}),
|
||||||
ReadTimeout: 30 * time.Second,
|
ReadTimeout: 30 * time.Second,
|
||||||
WriteTimeout: 30 * time.Second,
|
WriteTimeout: 30 * time.Second,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user