mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-24 17:33:22 +00:00
moved timeouts to config
This commit is contained in:
parent
ea0a29d4b9
commit
f5a0f6560d
@ -7,6 +7,9 @@ type ServerConfig struct {
|
|||||||
} `yaml:"mongodb"`
|
} `yaml:"mongodb"`
|
||||||
Server struct {
|
Server struct {
|
||||||
Port string `yaml:"port"`
|
Port string `yaml:"port"`
|
||||||
|
ReadTimeout int `yaml:"read_timeout"` // Timeout in seconds
|
||||||
|
WriteTimeout int `yaml:"write_timeout"` // Timeout in seconds
|
||||||
|
IdleTimeout int `yaml:"idle_timeout"` // Timeout in seconds
|
||||||
} `yaml:"server"`
|
} `yaml:"server"`
|
||||||
RateLimit RateLimitConfig `yaml:"rate_limit"`
|
RateLimit RateLimitConfig `yaml:"rate_limit"`
|
||||||
PubkeyWhitelist PubkeyWhitelistConfig `yaml:"pubkey_whitelist"`
|
PubkeyWhitelist PubkeyWhitelistConfig `yaml:"pubkey_whitelist"`
|
||||||
|
7
main.go
7
main.go
@ -62,9 +62,9 @@ func startServer(config *configTypes.ServerConfig, mux *http.ServeMux) {
|
|||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: config.Server.Port,
|
Addr: config.Server.Port,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadTimeout: 10 * time.Second,
|
ReadTimeout: time.Duration(config.Server.ReadTimeout) * time.Second,
|
||||||
WriteTimeout: 10 * time.Second,
|
WriteTimeout: time.Duration(config.Server.WriteTimeout) * time.Second,
|
||||||
IdleTimeout: 120 * time.Second,
|
IdleTimeout: time.Duration(config.Server.IdleTimeout) * time.Second,
|
||||||
}
|
}
|
||||||
fmt.Printf("Server is running on http://localhost%s\n", config.Server.Port)
|
fmt.Printf("Server is running on http://localhost%s\n", config.Server.Port)
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
@ -72,6 +72,7 @@ func startServer(config *configTypes.ServerConfig, mux *http.ServeMux) {
|
|||||||
fmt.Println("Error starting server:", err)
|
fmt.Println("Error starting server:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var wsServer = &websocket.Server{
|
var wsServer = &websocket.Server{
|
||||||
Handshake: func(config *websocket.Config, r *http.Request) error {
|
Handshake: func(config *websocket.Config, r *http.Request) error {
|
||||||
// Skip origin check
|
// Skip origin check
|
||||||
|
Loading…
Reference in New Issue
Block a user