mirror of https://github.com/status-im/fathom.git
23 lines
496 B
Go
23 lines
496 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/dannyvankooten/ana/count"
|
|
)
|
|
|
|
// URL: /api/screen-resolutions
|
|
var GetScreenResolutionsHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
before, after := getRequestedPeriods(r)
|
|
|
|
// get total
|
|
total := count.Visitors(before, after)
|
|
|
|
// get rows
|
|
results := count.Screens(before, after, getRequestedLimit(r), total)
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(results)
|
|
})
|