2018-05-06 11:53:19 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2018-05-08 14:57:08 +02:00
|
|
|
"github.com/gobuffalo/packr"
|
2018-05-06 11:53:19 +02:00
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2018-05-08 14:57:08 +02:00
|
|
|
func Routes() *mux.Router {
|
2018-05-06 11:53:19 +02:00
|
|
|
// register routes
|
|
|
|
r := mux.NewRouter()
|
|
|
|
r.Handle("/collect", NewCollectHandler()).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/session", LoginHandler).Methods(http.MethodPost)
|
|
|
|
r.Handle("/api/session", LogoutHandler).Methods(http.MethodDelete)
|
|
|
|
|
2018-05-07 16:05:53 +02:00
|
|
|
r.Handle("/api/stats/site/pageviews", Authorize(GetSiteStatsPageviewsHandler)).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/stats/site/visitors", Authorize(GetSiteStatsVisitorsHandler)).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/stats/site/duration", Authorize(GetSiteStatsDurationHandler)).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/stats/site/bounces", Authorize(GetSiteStatsBouncesHandler)).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/stats/site/realtime", Authorize(GetSiteStatsRealtimeHandler)).Methods(http.MethodGet)
|
2018-05-06 11:53:19 +02:00
|
|
|
|
2018-05-07 19:20:58 +02:00
|
|
|
r.Handle("/api/stats/pages", Authorize(GetPageStatsHandler)).Methods(http.MethodGet)
|
|
|
|
r.Handle("/api/stats/referrers", Authorize(GetReferrerStatsHandler)).Methods(http.MethodGet)
|
2018-05-07 17:01:20 +02:00
|
|
|
|
2018-05-08 14:57:08 +02:00
|
|
|
r.Path("/tracker.js").Handler(http.FileServer(packr.NewBox("./../../build/js")))
|
|
|
|
r.PathPrefix("/").Handler(http.FileServer(packr.NewBox("./../../build")))
|
2018-05-06 11:53:19 +02:00
|
|
|
return r
|
|
|
|
}
|