mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-12 11:18:35 -07:00
re-add /check as per discussion
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user