mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
25 lines
407 B
Go
25 lines
407 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"novamd/internal/db"
|
|
)
|
|
|
|
func (h *BaseHandler) GetUser(db *db.DB) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ctx, ok := h.getContext(w, r)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
user, err := db.GetUserByID(ctx.UserID)
|
|
if err != nil {
|
|
http.Error(w, "Failed to get user", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
respondJSON(w, user)
|
|
}
|
|
}
|