Nashboard/server/handlersUser.go

22 lines
468 B
Go

package server
import (
"git.nefrace.ru/nefrace/nashboard/storage"
"go.mongodb.org/mongo-driver/bson"
)
func (s Server) handleGetMe(c Context) error {
ctx := c.R.Context()
user := ctx.Value(CtxValue("user")).(*storage.User)
return c.WriteJSON(200, user)
}
func (s Server) handleAllUsers(c Context) error {
users, err := s.Db.GetUsers(&bson.D{})
if err != nil {
return ApiError{Status: 500, Err: "can't collect users"}
}
return c.WriteJSON(200, users)
}