mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-10 14:19:09 -07:00
tracker: record announce/scrape stats in handlers
This deduplicates code tracking the stats code tracking announces and scrapes for each protocol. The down side is that it isn't aware of any failures writing responses, but it was already being called before the write to a response for HTTP.
This commit is contained in:
@@ -86,8 +86,6 @@ func handleTorrentError(err error, w *Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
stats.RecordEvent(stats.Announce)
|
||||
|
||||
writer := &Writer{w}
|
||||
ann, err := s.newAnnounce(r, p)
|
||||
if err != nil {
|
||||
@@ -98,8 +96,6 @@ func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprou
|
||||
}
|
||||
|
||||
func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
stats.RecordEvent(stats.Scrape)
|
||||
|
||||
writer := &Writer{w}
|
||||
scrape, err := s.newScrape(r, p)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user