Allow HTTP timeouts to be configurable
This commit is contained in:
parent
50495bc774
commit
017810a752
6
main.go
6
main.go
|
@ -31,6 +31,7 @@ type Config struct {
|
||||||
BasicAuthPtr *string
|
BasicAuthPtr *string
|
||||||
UsernameHeaderPtr *string
|
UsernameHeaderPtr *string
|
||||||
GroupsHeaderPtr *string
|
GroupsHeaderPtr *string
|
||||||
|
TimeoutPtr *int
|
||||||
CookieSecret string
|
CookieSecret string
|
||||||
AllowAllPtr *bool
|
AllowAllPtr *bool
|
||||||
}
|
}
|
||||||
|
@ -47,6 +48,7 @@ func main() {
|
||||||
config.BasicAuthPtr = flag.String("basic-auth", "", "HTTP Basic authentication credentials to let through directly")
|
config.BasicAuthPtr = flag.String("basic-auth", "", "HTTP Basic authentication credentials to let through directly")
|
||||||
config.UsernameHeaderPtr = flag.String("username-header", "Discourse-User-Name", "Request header to pass authenticated username into")
|
config.UsernameHeaderPtr = flag.String("username-header", "Discourse-User-Name", "Request header to pass authenticated username into")
|
||||||
config.GroupsHeaderPtr = flag.String("groups-header", "Discourse-User-Groups", "Request header to pass authenticated groups into")
|
config.GroupsHeaderPtr = flag.String("groups-header", "Discourse-User-Groups", "Request header to pass authenticated groups into")
|
||||||
|
config.TimeoutPtr = flag.Int("timeout", 10, "Read/write timeout")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -95,8 +97,8 @@ func main() {
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: *config.ListenUriPtr,
|
Addr: *config.ListenUriPtr,
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
ReadTimeout: 10 * time.Second,
|
ReadTimeout: time.Duration(*config.TimeoutPtr) * time.Second,
|
||||||
WriteTimeout: 10 * time.Second,
|
WriteTimeout: time.Duration(*config.TimeoutPtr) * time.Second,
|
||||||
MaxHeaderBytes: 1 << 20,
|
MaxHeaderBytes: 1 << 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue