From 443fb4b70d15ffdb9d88478d93416dce9213db5f Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sun, 8 Feb 2015 02:20:48 -0500 Subject: [PATCH] http: add GET route for clients --- http/http.go | 1 + http/routes.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/http/http.go b/http/http.go index 9e3c461..967c7ce 100644 --- a/http/http.go +++ b/http/http.go @@ -83,6 +83,7 @@ func newRouter(s *Server) *httprouter.Router { } if s.config.ClientWhitelistEnabled { + r.GET("/clients/:clientID", makeHandler(s.getClient)) r.PUT("/clients/:clientID", makeHandler(s.putClient)) r.DELETE("/clients/:clientID", makeHandler(s.delClient)) } diff --git a/http/routes.go b/http/routes.go index fc40c30..a7eae79 100644 --- a/http/routes.go +++ b/http/routes.go @@ -178,6 +178,13 @@ func (s *Server) delUser(w http.ResponseWriter, r *http.Request, p httprouter.Pa return http.StatusOK, nil } +func (s *Server) getClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) { + if err := s.tracker.ClientApproved(p.ByName("clientID")); err != nil { + return http.StatusNotFound, err + } + return http.StatusOK, nil +} + func (s *Server) putClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) { s.tracker.PutClient(p.ByName("clientID")) return http.StatusOK, nil