1
0
Fork 0
empact/server/api.go

34 lines
748 B
Go
Raw Normal View History

2015-03-05 15:25:26 +00:00
package server
import (
"encoding/json"
"net/http"
"github.com/localhots/empact/db"
)
2015-03-06 11:18:15 +00:00
func apiOrgsHandler(w http.ResponseWriter, r *http.Request) {
2015-03-05 15:25:26 +00:00
login := currentUser(r)
orgs := db.UserOrgs(login)
b, _ := json.Marshal(orgs)
2015-03-06 10:56:46 +00:00
w.Header().Set("Content-Type", "application/json; charset=utf8")
w.Write(b)
}
2015-03-06 11:18:15 +00:00
func apiTeamsHandler(w http.ResponseWriter, r *http.Request) {
2015-03-06 10:56:46 +00:00
teams := db.OrgTeams(r.FormValue("org"))
b, _ := json.Marshal(teams)
w.Header().Set("Content-Type", "application/json; charset=utf8")
2015-03-05 15:25:26 +00:00
w.Write(b)
}
2015-03-06 11:18:15 +00:00
func apiReposHandler(w http.ResponseWriter, r *http.Request) {
repos := db.OrgRepos(r.FormValue("org"))
b, _ := json.Marshal(repos)
w.Header().Set("Content-Type", "application/json; charset=utf8")
w.Write(b)
}