Add user info endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
24
site-api.go
24
site-api.go
@ -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() {
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user