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