From 837e83dc0efb2a8ff0565ffb4257c8517cec0702 Mon Sep 17 00:00:00 2001 From: romanskijdev Date: Mon, 29 Jun 2026 22:46:33 +0300 Subject: [PATCH] added new time return route --- .../rest_admin_service/handlers/auth/handlers.go | 15 +++++++++++++++ .../rest_admin_service/handlers/auth/routes.go | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/service/rest_admin_service/handlers/auth/handlers.go b/service/rest_admin_service/handlers/auth/handlers.go index 91923b5..9625045 100644 --- a/service/rest_admin_service/handlers/auth/handlers.go +++ b/service/rest_admin_service/handlers/auth/handlers.go @@ -18,6 +18,21 @@ import ( "github.com/sirupsen/logrus" ) +// GetServerTimeHandler возвращает текущее серверное время для синхронизации с клиентом +// @Summary Получить серверное время +// @Description Публичный endpoint для синхронизации часов клиента с сервером +// @Tags public +// @Produce json +// @Success 200 {object} map[string]interface{} +// @Router /api/time [get] +func (s *AuthReg) GetServerTimeHandler(w http.ResponseWriter, r *http.Request) (interface{}, error) { + now := time.Now().UTC() + return map[string]interface{}{ + "timestamp": now.Unix(), + "iso": now.Format(time.RFC3339), + }, nil +} + // TokenAuthHandler // @Summary Авторизация при помощи JWT-токена // @Description Авторизация при помощи JWT-токена diff --git a/service/rest_admin_service/handlers/auth/routes.go b/service/rest_admin_service/handlers/auth/routes.go index eb53fb9..97dd52d 100644 --- a/service/rest_admin_service/handlers/auth/routes.go +++ b/service/rest_admin_service/handlers/auth/routes.go @@ -24,9 +24,10 @@ func RegisterAuthRoutes( ipc: ipc, } + handlers.RegisterRoute(r, http.MethodGet, "/api/time", s.GetServerTimeHandler) + r.Route("/api", func(r chi.Router) { r.Use(handlers.AccessCodeVerifier(ipc.Config)) - handlers.RegisterRoute(r, http.MethodPost, oauthURLogin, s.LoginByPasswordHandler) }) -- 2.43.0