summaryrefslogtreecommitdiff
path: root/internal/router/router.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-09 20:34:27 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-09 20:34:27 +0200
commitdc338dc881ead40723f0540aac7fe894f58b174d (patch)
treea000a065ffe219683f68520dd66b12aa1506a9fa /internal/router/router.go
parentFix token sweep (#19) (diff)
downloadgotosocial-dc338dc881ead40723f0540aac7fe894f58b174d.tar.xz
Webfinger + Small fixes (#20)
Diffstat (limited to 'internal/router/router.go')
-rw-r--r--internal/router/router.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/internal/router/router.go b/internal/router/router.go
index 0f1f288bd..cdd079634 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -25,6 +25,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "time"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
@@ -140,7 +141,13 @@ func New(config *config.Config, logger *logrus.Logger) (Router, error) {
engine.LoadHTMLGlob(tmPath)
// create the actual http server here
- var s *http.Server
+ s := &http.Server{
+ Handler: engine,
+ ReadTimeout: 1 * time.Second,
+ WriteTimeout: 1 * time.Second,
+ IdleTimeout: 30 * time.Second,
+ ReadHeaderTimeout: 2 * time.Second,
+ }
var m *autocert.Manager
// We need to spawn the underlying server slightly differently depending on whether lets encrypt is enabled or not.
@@ -154,17 +161,11 @@ func New(config *config.Config, logger *logrus.Logger) (Router, error) {
Email: config.LetsEncryptConfig.EmailAddress,
}
// and create an HTTPS server
- s = &http.Server{
- Addr: ":https",
- TLSConfig: m.TLSConfig(),
- Handler: engine,
- }
+ s.Addr = ":https"
+ s.TLSConfig = m.TLSConfig()
} else {
// le is NOT enabled, so just serve bare requests on port 8080
- s = &http.Server{
- Addr: ":8080",
- Handler: engine,
- }
+ s.Addr = ":8080"
}
return &router{