summaryrefslogtreecommitdiff
path: root/internal/router/router.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-15 11:58:11 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-15 11:58:11 +0200
commitcc48294c31a76e94fa879ad0d8d5dbd7e94c651b (patch)
tree7c26d33b41bab33bbdfbba540958444f4c296602 /internal/router/router.go
parentMediahandler (#21) (diff)
downloadgotosocial-cc48294c31a76e94fa879ad0d8d5dbd7e94c651b.tar.xz
Inbox post (#22)
Inbox POST from federated servers now working for statuses and follow requests. Follow request client API added. Start work on federating outgoing messages. Other fixes and changes/tidying up.
Diffstat (limited to 'internal/router/router.go')
-rw-r--r--internal/router/router.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/router/router.go b/internal/router/router.go
index cdd079634..eed85771f 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -27,6 +27,7 @@ import (
"path/filepath"
"time"
+ "github.com/gin-contrib/cors"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
"github.com/gin-gonic/gin"
@@ -123,6 +124,14 @@ func New(config *config.Config, logger *logrus.Logger) (Router, error) {
// create the actual engine here -- this is the core request routing handler for gts
engine := gin.Default()
+ engine.Use(cors.New(cors.Config{
+ AllowAllOrigins: true,
+ AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"},
+ AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization"},
+ AllowCredentials: false,
+ MaxAge: 12 * time.Hour,
+ }))
+ engine.MaxMultipartMemory = 8 << 20 // 8 MiB
// create a new session store middleware
store, err := sessionStore()
@@ -143,10 +152,10 @@ func New(config *config.Config, logger *logrus.Logger) (Router, error) {
// create the actual http server here
s := &http.Server{
Handler: engine,
- ReadTimeout: 1 * time.Second,
- WriteTimeout: 1 * time.Second,
+ ReadTimeout: 60 * time.Second,
+ WriteTimeout: 5 * time.Second,
IdleTimeout: 30 * time.Second,
- ReadHeaderTimeout: 2 * time.Second,
+ ReadHeaderTimeout: 30 * time.Second,
}
var m *autocert.Manager