mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-15 07:40:59 +00:00
20b3f84f77
* fix(web): report unexpected HTTP serve failures * test(web): cover normal close and all HTTP servers --------- Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
18 lines
487 B
Go
18 lines
487 B
Go
package network
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
"net/http"
|
|
|
|
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
|
)
|
|
|
|
// ServeHTTP runs a panel HTTP server and records unexpected listener failures.
|
|
// A normal Shutdown returns http.ErrServerClosed and is intentionally silent.
|
|
func ServeHTTP(server *http.Server, listener net.Listener, name string) {
|
|
if err := server.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
|
logger.Error(name, " stopped unexpectedly: ", err)
|
|
}
|
|
}
|