1
0
Fork 0
empact/server/api.go

38 lines
881 B
Go
Raw Normal View History

2015-03-05 15:25:26 +00:00
package server
import (
"net/http"
"github.com/localhots/empact/db"
)
func apiUserOrgsHandler(w http.ResponseWriter, r *http.Request) {
2015-03-07 14:56:02 +00:00
req, _ := parseRequest(w, r)
orgs := db.UserOrgs(req.login)
req.respondWith(orgs)
2015-03-06 10:56:46 +00:00
}
func apiOrgTeamsHandler(w http.ResponseWriter, r *http.Request) {
2015-03-07 14:56:02 +00:00
req, stat := parseRequest(w, r)
2015-03-08 11:17:56 +00:00
teams := db.OrgTeams(stat.Org)
2015-03-07 14:56:02 +00:00
req.respondWith(teams)
2015-03-05 15:25:26 +00:00
}
2015-03-06 11:18:15 +00:00
func apiOrgUsersHandler(w http.ResponseWriter, r *http.Request) {
2015-03-14 17:34:37 +00:00
req, stat := parseRequest(w, r)
users := db.OrgUsers(stat.Org)
req.respondWith(users)
}
func apiOrgReposHandler(w http.ResponseWriter, r *http.Request) {
2015-03-07 14:56:02 +00:00
req, stat := parseRequest(w, r)
2015-03-08 11:17:56 +00:00
repos := db.OrgRepos(stat.Org)
2015-03-07 14:56:02 +00:00
req.respondWith(repos)
2015-03-06 11:18:15 +00:00
}
2015-03-22 13:23:18 +00:00
func apiOrgWeekRangeHandler(w http.ResponseWriter, r *http.Request) {
req, stat := parseRequest(w, r)
min, max := db.OrgWeekRange(stat.Org)
req.respondWith([]int{min, max})
}