github.com/miguelangel-nubla/oauth2commander@v0.3.7/oauth2server/endpoints.go (about) 1 package oauth2server 2 3 import ( 4 "encoding/json" 5 "net/http" 6 ) 7 8 func (app *Oauth2Commander) EndpointValues(w http.ResponseWriter, r *http.Request) { 9 userInfo := app.templateVariables(w, r) 10 11 // Serialize to JSON 12 userInfoJSON, err := json.Marshal(userInfo) 13 if err != nil { 14 http.Error(w, "Failed to serialize user info to JSON", http.StatusInternalServerError) 15 return 16 } 17 18 // Set the content type and write the JSON response 19 w.Header().Set("Content-Type", "application/json") 20 w.Write(userInfoJSON) 21 }