Merge pull request #433 from SecurityBrewery/server-timeout

Add server timeout
This commit is contained in:
Jonas Plum
2022-09-29 23:43:25 +02:00
committed by GitHub
3 changed files with 15 additions and 3 deletions

View File

@@ -28,7 +28,6 @@ linters:
- goprintffuncname
- gosec
- grouper
- ifshort
- importas
- ireturn
- misspell
@@ -50,6 +49,7 @@ linters:
- bodyclose
- contextcheck
- gosimple
- ifshort
- nilerr
- noctx
- rowserrcheck

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
"time"
"github.com/arangodb/go-driver"
@@ -68,7 +69,12 @@ func main() {
api.Proxy("http://localhost:8080/")(writer, request)
})
if err := http.ListenAndServe(fmt.Sprintf(":%d", config.Port), theCatalyst.Server); err != nil {
server := &http.Server{
Addr: fmt.Sprintf(":%d", config.Port),
ReadHeaderTimeout: 3 * time.Second,
Handler: theCatalyst.Server,
}
if err := server.ListenAndServe(); err != nil {
log.Fatal(err)
}
}

View File

@@ -5,6 +5,7 @@ import (
"io/fs"
"log"
"net/http"
"time"
"github.com/SecurityBrewery/catalyst"
"github.com/SecurityBrewery/catalyst/cmd"
@@ -30,7 +31,12 @@ func main() {
staticHandlerFunc := http.HandlerFunc(api.VueStatic(fsys))
theCatalyst.Server.Get("/ui/*", http.StripPrefix("/ui", staticHandlerFunc).ServeHTTP)
if err := http.ListenAndServe(fmt.Sprintf(":%d", config.Port), theCatalyst.Server); err != nil {
server := &http.Server{
Addr: fmt.Sprintf(":%d", config.Port),
ReadHeaderTimeout: 3 * time.Second,
Handler: theCatalyst.Server,
}
if err := server.ListenAndServe(); err != nil {
log.Fatal(err)
}
}