sessions/internal/router/rest/user.go
Dawid Wysokiński 786cc60e38
All checks were successful
continuous-integration/drone/push Build is passing
feat: add a new REST endpoint - GET /api/v1/user/sessions/:server (#14)
Reviewed-on: #14
2022-11-25 05:55:31 +00:00

26 lines
666 B
Go

package rest
import (
"net/http"
"gitea.dwysokinski.me/twhelp/sessions/internal/router/rest/internal/model"
)
type userHandler struct {
}
// @ID getCurrentUser
// @Summary Get the authenticated user
// @Description Get the authenticated user
// @Tags users
// @Produce json
// @Success 200 {object} model.GetUserResp
// @Failure 401 {object} model.ErrorResp
// @Failure 500 {object} model.ErrorResp
// @Security ApiKeyAuth
// @Router /user [get]
func (h *userHandler) getCurrent(w http.ResponseWriter, r *http.Request) {
u, _ := userFromContext(r.Context())
renderJSON(w, http.StatusOK, model.NewGetUserResp(u))
}