Teams api
This commit is contained in:
		
							parent
							
								
									2c4de085e7
								
							
						
					
					
						commit
						4b6f79f366
					
				@ -8,10 +8,18 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func orgsListHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	jsonHandler(w, r)
 | 
			
		||||
	login := currentUser(r)
 | 
			
		||||
	orgs := db.UserOrgs(login)
 | 
			
		||||
 | 
			
		||||
	b, _ := json.Marshal(orgs)
 | 
			
		||||
 | 
			
		||||
	w.Header().Set("Content-Type", "application/json; charset=utf8")
 | 
			
		||||
	w.Write(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func orgTeamsHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	teams := db.OrgTeams(r.FormValue("org"))
 | 
			
		||||
	b, _ := json.Marshal(teams)
 | 
			
		||||
 | 
			
		||||
	w.Header().Set("Content-Type", "application/json; charset=utf8")
 | 
			
		||||
	w.Write(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ import (
 | 
			
		||||
	"net/url"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/empact/config"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/empact/task"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,15 +21,12 @@ func init() {
 | 
			
		||||
	http.HandleFunc("/", sessionHandler)
 | 
			
		||||
	http.HandleFunc("/api/", authHandler)
 | 
			
		||||
	http.HandleFunc("/api/orgs", orgsListHandler)
 | 
			
		||||
	http.HandleFunc("/api/teams", orgTeamsHandler)
 | 
			
		||||
	http.HandleFunc("/auth/hello", authHelloHandler)
 | 
			
		||||
	http.HandleFunc("/auth/signin", authSigninHandler)
 | 
			
		||||
	http.HandleFunc("/auth/callback", authCallbackHandler)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func jsonHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	w.Header().Set("Content-Type", "application/json; charset=utf8")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Start() {
 | 
			
		||||
	fmt.Println("Starting server at http://localhost:8080")
 | 
			
		||||
	http.ListenAndServe(":8080", nil)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user