Skip to content

Commit

Permalink
add: server timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
auula committed Jan 15, 2024
1 parent 538159c commit 2605874
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
_IPv4 = localIPv4Address()
)

const timeout = time.Second * 3

type HttpServer struct {
s *http.Server
closed int32
Expand All @@ -32,8 +34,8 @@ func New(opt *conf.ServerConfig) *HttpServer {
s: &http.Server{
Handler: api.Root,
Addr: net.JoinHostPort(_IPv4, strconv.Itoa(opt.Port)),
WriteTimeout: 3 * time.Second,
ReadTimeout: 3 * time.Second,
WriteTimeout: timeout,
ReadTimeout: timeout,
},
port: opt.Port,
}
Expand Down

0 comments on commit 2605874

Please sign in to comment.