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