|
- package main
-
- import (
- "biukop.com/sfm/loan"
- "net/http"
- )
-
- func apiV1UserReward(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
-
- if ss.User == "" {
- apiV1Client403Error(w, r, ss)
- return
- }
-
- userId := ss.User
- if ss.GetRole() == "admin" { //allow admin to query other user
- userId = r.URL.Path[len(apiV1Prefix+"user-reward/"):] //remove prefix
- }
-
- data := loan.GetUserReward(userId)
- apiV1SendJson(data, w, r, ss)
- }
|