fathom: github.com/usefathom/fathom/pkg/api Index | Files

package api

import "github.com/usefathom/fathom/pkg/api"


Package Files

api.go auth.go collect.go health.go http.go page_stats.go params.go referrer_stats.go routes.go site_stats.go sites.go

func HandleError Uses

func HandleError(w http.ResponseWriter, r *http.Request, err error)

HandleError handles errors

func HandlerFunc Uses

func HandlerFunc(fn Handler) http.HandlerFunc

HandlerFunc takes a custom Handler func and converts it to http.HandlerFunc

func NotFoundHandler Uses

func NotFoundHandler(box *packr.Box) http.Handler

type API Uses

type API struct {
    // contains filtered or unexported fields

func New Uses

func New(db datastore.Datastore, secret string) *API

New instantiates a new API object

func (*API) Authorize Uses

func (api *API) Authorize(next http.Handler) http.Handler

Authorize is middleware that aborts the request if unauthorized

func (*API) CreateSession Uses

func (api *API) CreateSession(w http.ResponseWriter, r *http.Request) error

URL: POST /api/session

func (*API) DeleteSession Uses

func (api *API) DeleteSession(w http.ResponseWriter, r *http.Request) error

URL: DELETE /api/session

func (*API) DeleteSiteHandler Uses

func (api *API) DeleteSiteHandler(w http.ResponseWriter, r *http.Request) error

DELETE /api/sites/{id}

func (*API) GetAggregatedPageStatsHandler Uses

func (api *API) GetAggregatedPageStatsHandler(w http.ResponseWriter, r *http.Request) error

URL: /api/sites/{id:[0-9]+}/stats/pages/agg

func (*API) GetAggregatedPageStatsPageviewsHandler Uses

func (api *API) GetAggregatedPageStatsPageviewsHandler(w http.ResponseWriter, r *http.Request) error

func (*API) GetAggregatedReferrerStatsHandler Uses

func (api *API) GetAggregatedReferrerStatsHandler(w http.ResponseWriter, r *http.Request) error

func (*API) GetAggregatedReferrerStatsPageviewsHandler Uses

func (api *API) GetAggregatedReferrerStatsPageviewsHandler(w http.ResponseWriter, r *http.Request) error

func (*API) GetAggregatedSiteStatsHandler Uses

func (api *API) GetAggregatedSiteStatsHandler(w http.ResponseWriter, r *http.Request) error

URL: /api/sites/{id:[0-9]+}/stats/site/agg

func (*API) GetSession Uses

func (api *API) GetSession(w http.ResponseWriter, r *http.Request) error

GET /api/session

func (*API) GetSiteStatsHandler Uses

func (api *API) GetSiteStatsHandler(w http.ResponseWriter, r *http.Request) error

URL: /api/sites/{id:[0-9]+}/stats/site

func (*API) GetSiteStatsRealtimeHandler Uses

func (api *API) GetSiteStatsRealtimeHandler(w http.ResponseWriter, r *http.Request) error

URL: /api/sites/{id:[0-9]+}/stats/site/realtime

func (*API) GetSitesHandler Uses

func (api *API) GetSitesHandler(w http.ResponseWriter, r *http.Request) error

GET /api/sites

func (*API) Health Uses

func (api *API) Health(w http.ResponseWriter, _ *http.Request) error

GET /health

func (*API) Routes Uses

func (api *API) Routes() *mux.Router

func (*API) SaveSiteHandler Uses

func (api *API) SaveSiteHandler(w http.ResponseWriter, r *http.Request) error

POST /api/sites POST /api/sites/{id}

type Collector Uses

type Collector struct {
    Store     datastore.Datastore
    Pageviews chan *models.Pageview
    // contains filtered or unexported fields

func NewCollector Uses

func NewCollector(store datastore.Datastore) *Collector

func (*Collector) ServeHTTP Uses

func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Handler Uses

type Handler func(w http.ResponseWriter, r *http.Request) error

Handler is our custom HTTP handler with error returns

func (Handler) ServeHTTP Uses

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Params Uses

type Params struct {
    SiteID    int64
    Offset    int
    Limit     int
    StartDate time.Time
    EndDate   time.Time

Params defines the commonly used API parameters

func GetRequestParams Uses

func GetRequestParams(r *http.Request) *Params

GetRequestParams parses the query parameters and returns commonly used API parameters, with defaults

Package api imports 17 packages (graph) and is imported by 1 packages. Updated 2019-01-08. Refresh now. Tools for package owners.