mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-14 23:08:36 -07:00
http: add GET route for clients
This commit is contained in:
@@ -83,6 +83,7 @@ func newRouter(s *Server) *httprouter.Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.config.ClientWhitelistEnabled {
|
if s.config.ClientWhitelistEnabled {
|
||||||
|
r.GET("/clients/:clientID", makeHandler(s.getClient))
|
||||||
r.PUT("/clients/:clientID", makeHandler(s.putClient))
|
r.PUT("/clients/:clientID", makeHandler(s.putClient))
|
||||||
r.DELETE("/clients/:clientID", makeHandler(s.delClient))
|
r.DELETE("/clients/:clientID", makeHandler(s.delClient))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,13 @@ func (s *Server) delUser(w http.ResponseWriter, r *http.Request, p httprouter.Pa
|
|||||||
return http.StatusOK, nil
|
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) {
|
func (s *Server) putClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
s.tracker.PutClient(p.ByName("clientID"))
|
s.tracker.PutClient(p.ByName("clientID"))
|
||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user