fathom/api/referrers.go

17 lines
404 B
Go
Raw Normal View History

package api
import (
2016-12-11 14:50:01 +01:00
"encoding/json"
"net/http"
2016-12-24 10:00:45 +02:00
"github.com/dannyvankooten/ana/count"
)
// URL: /api/referrers
var GetReferrersHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2016-12-11 14:50:01 +01:00
before, after := getRequestedPeriods(r)
results := count.Referrers(before, after, getRequestedLimit(r))
2016-12-11 14:50:01 +01:00
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(results)
})