aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-22 13:17:55 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-22 13:32:35 +0800
commit7a6f71ac73b41a38e9982bea3d46a87c327bd77a (patch)
tree92d5b637f57080af40c2f42834282df58a4e21a3 /main.go
parentfedauth: Use NewRequestWithContext (diff)
downloadforge-7a6f71ac73b41a38e9982bea3d46a87c327bd77a.tar.gz
forge-7a6f71ac73b41a38e9982bea3d46a87c327bd77a.tar.zst
forge-7a6f71ac73b41a38e9982bea3d46a87c327bd77a.zip
Initial linting
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 8 insertions, 1 deletions
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())
}
}()