Skip to content

Commit

Permalink
add x-knoq-version header
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji8 committed Dec 7, 2021
1 parent a3b08f1 commit 628f231
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions router/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 628f231

Please sign in to comment.