re-add /check as per discussion

This commit is contained in:
Jimmy Zelinskie 2014-07-22 01:19:09 -04:00
parent 858258f884
commit 4514705363
2 changed files with 10 additions and 0 deletions

View file

@ -68,6 +68,7 @@ func newRouter(s *Server) *httprouter.Router {
r.PUT("/torrents/:infohash", makeHandler(s.putTorrent)) r.PUT("/torrents/:infohash", makeHandler(s.putTorrent))
r.DELETE("/torrents/:infohash", makeHandler(s.delTorrent)) r.DELETE("/torrents/:infohash", makeHandler(s.delTorrent))
r.GET("/check", makeHandler(s.check)) r.GET("/check", makeHandler(s.check))
r.GET("/stats", makeHandler(s.stats))
return r return r
} }

View file

@ -20,6 +20,15 @@ import (
const jsonContentType = "application/json; charset=UTF-8" const jsonContentType = "application/json; charset=UTF-8"
func (s *Server) check(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) { func (s *Server) check(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
_, err := w.Write([]byte("An easter egg goes here."))
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
func (s *Server) stats(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
w.Header().Set("Content-Type", jsonContentType) w.Header().Set("Content-Type", jsonContentType)
e := json.NewEncoder(w) e := json.NewEncoder(w)