diff --git a/.idea/.gitignore b/.idea/.gitignore index 0e820690b..930678c0c 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -7,3 +7,5 @@ /dataSources.local.xml # Editor-based HTTP Client requests /httpRequests/ +# GitHub Copilot persisted chat sessions +/copilot/chatSessions diff --git a/tools/config.go b/tools/config.go index f4c49aad3..8c357ee9a 100644 --- a/tools/config.go +++ b/tools/config.go @@ -168,8 +168,9 @@ type Config struct { Host string `yaml:"host"` ApiKey string `yaml:"apiKey"` } `yaml:"meili"` - VodURLTemplate string `yaml:"vodURLTemplate"` - CanonicalURL string `yaml:"canonicalURL"` + VodURLTemplate string `yaml:"vodURLTemplate"` + CanonicalURL string `yaml:"canonicalURL"` + Headers []Header `yaml:"headers"` } type MailConfig struct { @@ -180,6 +181,11 @@ type MailConfig struct { MaxMailsPerMinute int `yaml:"maxMailsPerMinute"` } +type Header struct { + Header string `yaml:"header"` + Value string `yaml:"value"` +} + func (Config) GetJWTKey() *rsa.PrivateKey { return jwtKey } diff --git a/tools/middlewares.go b/tools/middlewares.go index a1de2c36b..a29661368 100644 --- a/tools/middlewares.go +++ b/tools/middlewares.go @@ -29,6 +29,15 @@ type JWTClaims struct { SamlSubjectID *string // identifier of the SAML session (if any) } +func AddResponseHeaders() gin.HandlerFunc { + return func(c *gin.Context) { + for _, h := range Cfg.Headers { + c.Header(h.Header, h.Value) + } + c.Next() + } +} + func InitContext(daoWrapper dao.DaoWrapper) gin.HandlerFunc { return func(c *gin.Context) { // no context initialisation required for static assets. diff --git a/web/router.go b/web/router.go index d2881aa78..cbfadf874 100755 --- a/web/router.go +++ b/web/router.go @@ -151,6 +151,7 @@ func configMainRoute(router *gin.Engine) { // watch streamGroup.Use(tools.InitStream(daoWrapper)) + streamGroup.Use(tools.AddResponseHeaders()) streamGroup.GET("/w/:slug/:streamID", routes.WatchPage) streamGroup.GET("/w/:slug/:streamID/:version", routes.WatchPage) streamGroup.GET("/w/:slug/:streamID/chat/popup", routes.PopOutChat)