Merge pull request 'added new time return route' (#45) from fix-permissions into main
Deploy / deploy (push) Successful in 14s
Details
Deploy / deploy (push) Successful in 14s
Details
Reviewed-on: https://72.56.235.246.nip.io/gitea/romanskijdev/ruspet_portal_back/pulls/45
This commit is contained in:
commit
4c75ceff87
|
|
@ -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-токена
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue