mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: configurable request timeout
This commit is contained in:
parent
c3957ec0c8
commit
4d2a160ccb
@ -152,6 +152,7 @@ You can specify configuration options either via a config file (default: `config
|
||||
| `server.listen_ipv4` | `WAKAPI_LISTEN_IPV4` | `127.0.0.1` | IPv4 network address to listen on (leave blank to disable IPv4) |
|
||||
| `server.listen_ipv6` | `WAKAPI_LISTEN_IPV6` | `::1` | IPv6 network address to listen on (leave blank to disable IPv6) |
|
||||
| `server.listen_socket` | `WAKAPI_LISTEN_SOCKET` | - | UNIX socket to listen on (leave blank to disable UNIX socket) |
|
||||
| `server.timeout_sec` | `WAKAPI_TIMEOUT_SEC` | `30` | Request timeout in seconds |
|
||||
| `server.tls_cert_path` | `WAKAPI_TLS_CERT_PATH` | - | Path of SSL server certificate (leave blank to not use HTTPS) |
|
||||
| `server.tls_key_path` | `WAKAPI_TLS_KEY_PATH` | - | Path of SSL server private key (leave blank to not use HTTPS) |
|
||||
| `server.base_path` | `WAKAPI_BASE_PATH` | `/` | Web base path (change when running behind a proxy under a sub-path) |
|
||||
|
@ -4,6 +4,7 @@ server:
|
||||
listen_ipv4: 127.0.0.1 # leave blank to disable ipv4
|
||||
listen_ipv6: ::1 # leave blank to disable ipv6
|
||||
listen_socket: # leave blank to disable unix sockets
|
||||
timeout_sec: 30 # request timeout
|
||||
tls_cert_path: # leave blank to not use https
|
||||
tls_key_path: # leave blank to not use https
|
||||
port: 3000
|
||||
|
@ -99,6 +99,7 @@ type serverConfig struct {
|
||||
ListenIpV4 string `yaml:"listen_ipv4" default:"127.0.0.1" env:"WAKAPI_LISTEN_IPV4"`
|
||||
ListenIpV6 string `yaml:"listen_ipv6" default:"::1" env:"WAKAPI_LISTEN_IPV6"`
|
||||
ListenSocket string `yaml:"listen_socket" default:"" env:"WAKAPI_LISTEN_SOCKET"`
|
||||
TimeoutSec int `yaml:"timeout_sec" default:"30" env:"WAKAPI_TIMEOUT_SEC"`
|
||||
BasePath string `yaml:"base_path" default:"/" env:"WAKAPI_BASE_PATH"`
|
||||
PublicUrl string `yaml:"public_url" default:"http://localhost:3000" env:"WAKAPI_PUBLIC_URL"`
|
||||
TlsCertPath string `yaml:"tls_cert_path" default:"" env:"WAKAPI_TLS_CERT_PATH"`
|
||||
|
12
main.go
12
main.go
@ -250,8 +250,8 @@ func listen(handler http.Handler) {
|
||||
s4 = &http.Server{
|
||||
Handler: handler,
|
||||
Addr: bindString4,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
ReadTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
WriteTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,8 +261,8 @@ func listen(handler http.Handler) {
|
||||
s6 = &http.Server{
|
||||
Handler: handler,
|
||||
Addr: bindString6,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
ReadTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
WriteTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,8 +270,8 @@ func listen(handler http.Handler) {
|
||||
if config.Server.ListenSocket != "" {
|
||||
sSocket = &http.Server{
|
||||
Handler: handler,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
ReadTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
WriteTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
1.29.0
|
||||
1.29.1
|
||||
|
Loading…
Reference in New Issue
Block a user