func (t *Timer) ServeHTTP(w http.ResponseWriter, req *http.Request) {

	req.ParseForm()
	sortBy := req.Form.Get("sort")

	stats := &Stats{}
	stats.SortBy = strings.ToLower(sortBy)
	stats.Generated = time.Now()
	stats.UpTime = fmt.Sprintf("%s", stats.Generated.Sub(t.Since))
	// Read access OK for map?
	stats.Result = make([]*Stat, 0, len(t.routes))
	for k, v := range t.routes {
		stat := &Stat{}
		stat.Route = k
		stat.Count = v.Count
		stat.Tot = v.Tot
		stat.Avg = time.Duration(int64(v.Tot) / v.Count)
		stat.AvgAfter = time.Duration(int64(v.AfterTot) / v.Count)
		stat.AvgBefore = time.Duration(int64(v.BeforeTot) / v.Count)
		stat.Max = v.Max
		stat.Min = v.Min
		stats.Result = append(stats.Result, stat)
	}
	sort.Sort(sort.Reverse(stats))
	jsonData, _ := json.Marshal(stats)
	w.Write(jsonData)
}
func (t *Timer) ServeHTTP(w http.ResponseWriter, req *http.Request) {

	req.ParseForm()
	sortBy := req.Form.Get("sort")

	stats := &Stats{}
	stats.SortBy = strings.ToLower(sortBy)
	stats.Generated = time.Now()
	stats.UpTime = fmt.Sprintf("%s", stats.Generated.Sub(t.Since))
	
	stats.Result = make([]*Stat, 0, len(t.routes))
	for k, v := range t.routes {
		stat := &Stat{}
		stat.Route = k
		stat.Count = v.Count
		stat.Tot = v.Tot
		stat.Avg = time.Duration(int64(v.Tot) / v.Count)
		stat.AvgAfter = time.Duration(int64(v.AfterTot) / v.Count)
		stat.AvgBefore = time.Duration(int64(v.BeforeTot) / v.Count)
		stat.Max = v.Max
		stat.Min = v.Min
		stats.Result = append(stats.Result, stat)
	}
	sort.Sort(sort.Reverse(stats))
	jsonData, _ := json.Marshal(stats)
	w.Write(jsonData)
}
func ( t * Timer ) ServeHTTP ( w http . ResponseWriter , req * http . Request ) { req . ParseForm ( ) sortBy := req . Form . Get ( " " ) stats := & Stats { } stats . SortBy = strings . ToLower ( sortBy ) stats . Generated = time . Now ( ) stats . UpTime = fmt . Sprintf ( " " , stats . Generated . Sub ( t . Since ) ) // Read access OK for map? stats . Result = make ( [ ] * Stat , 0 , len ( t . routes ) ) for k , v := range t . routes { stat := & Stat { } stat . Route = k stat . Count = v . Count stat . Tot = v . Tot stat . Avg = time . Duration ( int64 ( v . Tot ) / v . Count ) stat . AvgAfter = time . Duration ( int64 ( v . AfterTot ) / v . Count ) stat . AvgBefore = time . Duration ( int64 ( v . BeforeTot ) / v . Count ) stat . Max = v . Max stat . Min = v . Min stats . Result = append ( stats . Result , stat ) } sort . Sort ( sort . Reverse ( stats ) ) jsonData , _ := json . Marshal ( stats ) w . Write ( jsonData ) }
// For serving statistics
For serving statistics