Create user
This commit is contained in:
@ -712,3 +712,15 @@ func (app *application) AllUsers(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
app.writeJSON(w, http.StatusOK, allUsers)
|
||||
}
|
||||
|
||||
func (app *application) OneUser(w http.ResponseWriter, r *http.Request) {
|
||||
id := chi.URLParam(r, "id")
|
||||
userID, _ := strconv.Atoi(id)
|
||||
user, err := app.DB.GetOneUser(userID)
|
||||
if err != nil {
|
||||
app.errorLog.Println(err)
|
||||
app.badRequest(w, r, err)
|
||||
return
|
||||
}
|
||||
app.writeJSON(w, http.StatusOK, user)
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ func (app *application) routes() http.Handler {
|
||||
mux.Post("/refund", app.RefundCharge)
|
||||
mux.Post("/cancel-subscription", app.CancelSubscription)
|
||||
mux.Post("/all-users", app.AllUsers)
|
||||
mux.Post("/all-users/{id}", app.OneUser)
|
||||
})
|
||||
mux.Post("/api/forgot-password", app.SendPasswordResetEmail)
|
||||
mux.Post("/api/reset-password", app.ResetPassword)
|
||||
|
Reference in New Issue
Block a user