api

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

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

HandleError handles errors

func HandlerFunc

func HandlerFunc(fn Handler) http.HandlerFunc

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

func NotFoundHandler

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

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func New

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

New instantiates a new API object

func (*API) Authorize

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

Authorize is middleware that aborts the request if unauthorized

func (*API) CreateSession

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

URL: POST /api/session

func (*API) DeleteSession

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

URL: DELETE /api/session

func (*API) DeleteSiteHandler

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

DELETE /api/sites/{id}

func (*API) GetAggregatedPageStatsHandler

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

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

func (*API) GetAggregatedPageStatsPageviewsHandler

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

func (*API) GetAggregatedReferrerStatsHandler

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

func (*API) GetAggregatedReferrerStatsPageviewsHandler

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

func (*API) GetAggregatedSiteStatsHandler

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

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

func (*API) GetSession

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

GET /api/session

func (*API) GetSiteStatsHandler

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

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

func (*API) GetSiteStatsRealtimeHandler

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

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

func (*API) GetSitesHandler

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

GET /api/sites

func (*API) Health

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

GET /health

func (*API) Routes

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

func (*API) SaveSiteHandler

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

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

type Collector

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

func NewCollector

func NewCollector(store datastore.Datastore) *Collector

func (*Collector) ServeHTTP

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

type Handler

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

Handler is our custom HTTP handler with error returns

func (Handler) ServeHTTP

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

type Params

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

Params defines the commonly used API parameters

func GetRequestParams

func GetRequestParams(r *http.Request) *Params

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL