mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 07:12:46 +01:00
Add server timeout
This commit is contained in:
@@ -28,7 +28,6 @@ linters:
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- grouper
|
||||
- ifshort
|
||||
- importas
|
||||
- ireturn
|
||||
- misspell
|
||||
@@ -50,6 +49,7 @@ linters:
|
||||
- bodyclose
|
||||
- contextcheck
|
||||
- gosimple
|
||||
- ifshort
|
||||
- nilerr
|
||||
- noctx
|
||||
- rowserrcheck
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user