mirror of
https://github.com/parkan/go-hauk.git
synced 2026-06-23 03:37:46 +02:00
enforce timeouts and request body cap
This commit is contained in:
12
main.go
12
main.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/parkan/go-hauk/api"
|
||||
"github.com/parkan/go-hauk/config"
|
||||
@@ -19,8 +20,17 @@ func main() {
|
||||
|
||||
srv := api.NewServer(cfg, redis)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: cfg.ListenAddr,
|
||||
Handler: srv,
|
||||
ReadHeaderTimeout: 10 * time.Second,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 30 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
|
||||
log.Printf("starting hauk on %s", cfg.ListenAddr)
|
||||
if err := http.ListenAndServe(cfg.ListenAddr, srv); err != nil {
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user