diff --git a/router/middleware.go b/router/middleware.go index 4d857b56..56b0e88d 100644 --- a/router/middleware.go +++ b/router/middleware.go @@ -74,6 +74,16 @@ func AccessLoggingMiddleware(logger *zap.Logger) echo.MiddlewareFunc { } } +// ServerVersionMiddleware X-KNOQ-VERSIONをレスポンスヘッダーを追加するミドルウェア +func ServerVersionMiddleware(version string) echo.MiddlewareFunc { + return func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + c.Response().Header().Set("X-KNOQ-VERSION", version) + return next(c) + } + } +} + // TraQUserMiddleware traQユーザーか判定するミドルウェア // TODO funcname fix func (h *Handlers) TraQUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc { diff --git a/router/router.go b/router/router.go index 57f0c600..7d327c07 100644 --- a/router/router.go +++ b/router/router.go @@ -46,6 +46,8 @@ func (h *Handlers) SetupRoute() *echo.Echo { } e.Use(session.Middleware(sessions.NewCookieStore(h.SessionKey))) + e.Use(ServerVersionMiddleware(domain.VERSION)) + // TODO fix "portal origin" e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"https://portal.trap.jp", "http://localhost:8080"},