Created
April 24, 2016 21:50
-
-
Save kpurdon/f97d75818790570a58a85b71a2893e28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetReposHandler returns a list of (public) repositories for a given GitHub user | |
func (a *App) GetReposHandler(w http.ResponseWriter, r *http.Request) { | |
user := r.FormValue("user") | |
if user == "" { | |
http.Error(w, "MISSING_ARG_USER", 400) | |
return | |
} | |
repos, err := a.repos.Get(user) | |
if err != nil { | |
http.Error(w, "INTERNAL_ERROR", 500) | |
return | |
} | |
b, err := json.Marshal(repos) | |
if err != nil { | |
http.Error(w, "INTERNAL_ERROR", 500) | |
return | |
} | |
w.Header().Set("Content-Type", "application/json") | |
w.Write(b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment