From 7a6f71ac73b41a38e9982bea3d46a87c327bd77a Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 22 Mar 2025 13:17:55 +0800 Subject: Initial linting --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index d2b1069..1530d90 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "net" "net/http" "syscall" + "time" "go.lindenii.runxiyu.org/lindenii-common/clog" ) @@ -86,9 +87,15 @@ func main() { } else if err != nil { clog.Fatal(1, "Listening HTTP: "+err.Error()) } + server := http.Server{ + Handler: &forgeHTTPRouter{}, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 60 * time.Second, + } //exhaustruct:ignore clog.Info("Listening HTTP on " + config.HTTP.Net + " " + config.HTTP.Addr) go func() { - if err = http.Serve(httpListener, &forgeHTTPRouter{}); err != nil { + if err = server.Serve(httpListener); err != nil && !errors.Is(err, http.ErrServerClosed) { clog.Fatal(1, "Serving HTTP: "+err.Error()) } }() -- cgit v1.2.3