Browse Source

Add user info endpoint

hkremer/rebranding
Gregory Rudolph 3 years ago
parent
commit
9803136783
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 24
      site-api.go

24
site-api.go

@ -179,6 +179,29 @@ func getVerifications(w http.ResponseWriter, r *http.Request) { @@ -179,6 +179,29 @@ func getVerifications(w http.ResponseWriter, r *http.Request) {
}
fmt.Fprintf(w, string(verifications))
}
func getUser(w http.ResponseWriter, r *http.Request) {
loggedIn, _ := detectUser(r, "getVerifications")
if !loggedIn {
notFoundPage(w, r)
return
}
vars := mux.Vars(r)
username := vars["userID"]
if len(username) == 0 {
username = r.FormValue("userID")
}
m, err := dg.GuildMember(config.GuildID, username)
if err != nil {
log.LogErrorType(err)
}
ret, err := json.Marshal(m)
if err != nil {
log.LogErrorType(err)
}
fmt.Fprintf(w, string(ret))
}
func runWeb() {
defer log.PanicSafe()
router := mux.NewRouter().StrictSlash(true)
@ -191,6 +214,7 @@ func runWeb() { @@ -191,6 +214,7 @@ func runWeb() {
router.HandleFunc("/api/verifications", getVerifications)
router.HandleFunc("/api/probations", getProbations)
router.HandleFunc("/api/passreq", reqPass)
router.HandleFunc("/api/user", getUser)
router.HandleFunc("/", greetUser)
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
log.LogInfo("Starting server")

Loading…
Cancel
Save