Documentation ¶
Overview ¶
package goatcounter implements the GoatCounter API
The GoatCounter API comprises multiple resources. Each is mapped to a Go type.
Index ¶
- type Client
- func (c *Client) Count() (*Count, error)
- func (c *Client) Do(ctx context.Context, method, url string, body io.Reader) ([]byte, error)
- func (c *Client) Exports() ExportsInterface
- func (c *Client) Paths() PathsInterface
- func (c *Client) Sites() SitesInterface
- func (c *Client) Stats() StatsInterface
- func (c *Client) Users() UsersInterface
- type ClientInterface
- type Count
- type ErrorResponse
- type Errors
- type ExportsClient
- type ExportsInterface
- type Hit
- type HitsResponse
- type Path
- type PathsClient
- type PathsInterface
- type PathsResponse
- type Site
- type SiteSettings
- type SitesClient
- type SitesInterface
- type SitesResponse
- type Stat
- type StatsClient
- type StatsInterface
- type Token
- type Total
- type User
- type UserSettings
- type UsersClient
- type UsersInterface
- type View
- type Widget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Code string // contains filtered or unexported fields }
Client is a type that implements methods for GoatCounter API client
func (*Client) Exports ¶
func (c *Client) Exports() ExportsInterface
Exports is a method that implements GoatCounter Exports endpoints Exports returns an implementation of ExportsInterface
func (*Client) Paths ¶
func (c *Client) Paths() PathsInterface
Paths is a method that implements GoatCounter Paths endpoints Paths returns an implementation of PathsInterface
func (*Client) Sites ¶
func (c *Client) Sites() SitesInterface
Sites is a method that implements GoatCounter Sites endpoints Sites returns an implementation of SitesInterface
func (*Client) Stats ¶
func (c *Client) Stats() StatsInterface
Stats is a method that implements GoatCounter Stats endpoints Stats returns an implementation of StatsInterface
func (*Client) Users ¶
func (c *Client) Users() UsersInterface
Users is a method that implements GoatCounter Users endpoints Users returns an implementation of UsersInterface
type ClientInterface ¶
type ClientInterface interface { Do(context.Context, string, string, io.Reader) ([]byte, error) // This method is not part of a resource type Count() (*Count, error) // These correspond to resource types defined on the API // /exports // /paths // /sites // /stats // /users Exports() ExportsInterface Paths() PathsInterface Sites() SitesInterface Stats() StatsInterface Users() UsersInterface }
ClientInterface is an interface that defines methods for GoatCounter API client
type ErrorResponse ¶
type ErrorResponse struct { // GError is used to avoid conflicting with the interface's Error method // The field must be Exported for JSON marshaling GError string `json:"error,omitempty"` Errors Errors `json:"errors,omitempty"` }
ErrorResponse is a type that represents GoatCounter API error responses ErrorResponse implements the error interface
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type ExportsClient ¶
type ExportsClient struct {
// contains filtered or unexported fields
}
ExportsClient is a type that implements methods for GoatCounter Exports endpoints
func (*ExportsClient) URL ¶
func (c *ExportsClient) URL(path string) string
Url is a method that returns the endpoint's method URL
type ExportsInterface ¶
ExportsInterface is an interface that defines methods for GoatCounter Exports endpoints
type HitsResponse ¶
type HitsResponse struct {
Hits []Hit `json:"hits"`
}
type PathsClient ¶
type PathsClient struct {
// contains filtered or unexported fields
}
PathsClient is a type that implements methods for GoatCounter Path endpoints
func (*PathsClient) List ¶
func (c *PathsClient) List() (*PathsResponse, error)
List is a method that implements GoatCounter's /paths method
func (*PathsClient) URL ¶
func (c *PathsClient) URL(path string) string
Url is a method that returns the endpoint's method URL
type PathsInterface ¶
type PathsInterface interface { List() (*PathsResponse, error) URL(string) string }
PathsInterface is an interface that defines methods on GoatCounter Paths endpoints
type PathsResponse ¶
type Site ¶
type Site struct { CNAME string `json:"cname"` CNAMESetupAt time.Time `json:"cname_setup_at"` Code string `json:"code"` CreatedAt time.Time `json:"created_at"` FirstHitAt time.Time `json:"first_hit_at"` ID int `json:"id"` LinkDomain string `json:"link_domain"` Parent int `json:"parent"` ReceivedData bool `json:"received_data"` Settings SiteSettings `json:"settings"` State string `json:"state"` UpdatedAt time.Time `json:"updated_at"` UserDefaults UserSettings `json:"user_defaults"` }
type SiteSettings ¶
type SiteSettings struct { AllowBosmang bool `json:"allow_bosmang"` AllowCounter bool `json:"allow_counter"` AllowEmbed []string `json:"allow_embed"` Collect int `json:"collect"` CollectRegions []string `json:"collect_regions"` DataRetention int `json:"data_retention"` IgnoreIPs []string `json:"ignore_ips"` Public string `json:"public"` Secret string `json:"secret"` }
type SitesClient ¶
type SitesClient struct {
// contains filtered or unexported fields
}
func (*SitesClient) List ¶
func (c *SitesClient) List() (*SitesResponse, error)
func (*SitesClient) URL ¶
func (c *SitesClient) URL(path string) string
type SitesInterface ¶
type SitesInterface interface { Get(string) (*Site, error) List() (*SitesResponse, error) URL(string) string }
SitesInterface is an interface that defines methods for GoatCounter Sites endpoints
type SitesResponse ¶
type SitesResponse struct {
Sites []Site `json:"sites"`
}
type StatsClient ¶
type StatsClient struct {
// contains filtered or unexported fields
}
StatsClient is a type that implements methods for GoatCounter Stats endpoints
func (*StatsClient) Hits ¶
func (c *StatsClient) Hits() (*HitsResponse, error)
Hits is a method that implements GoatCounter /stats/hits
func (*StatsClient) Total ¶
func (c *StatsClient) Total() (*Total, error)
Total is a method that implements GoatCounter /stats/total
func (*StatsClient) URL ¶
func (c *StatsClient) URL(path string) string
Url is a method that returns the endpoint's method URL
type StatsInterface ¶
type StatsInterface interface { Total() (*Total, error) Hits() (*HitsResponse, error) URL(string) string }
StatsInterface is an interface that defines methods for GoatCounter Stats endpoints
type User ¶
type User struct { ID int `json:"id"` Site int `json:"site"` Email string `json:"email"` EmailVerified bool `json:"email_verified"` TOTPVerified bool `json:"totp_verified"` Access map[string]string `json:"access"` LoginAt time.Time `json:"login_at"` OpenAt time.Time `json:"open_at"` ResetAt time.Time `json:"reset_at,omitempty"` Settings UserSettings `json:"settings"` LastReportAt time.Time `json:"last_report_at"` UpdatedAt time.Time `json:"updated_at"` Token Token `json:"token"` }
type UserSettings ¶
type UserSettings struct { TwentyFourHours bool `json:"twenty_four_hours"` SundayStartsWeek bool `json:"sunday_starts_week"` Language string `json:"language"` DateFormat string `json:"date_format"` NumberFormat int `json:"number_format"` TimeZone string `json:"timezone"` Widgets []Widget `json:"widgets"` Views []View `json:"views"` EmailReports int `json:"email_reports"` FewerNumbers bool `json:"fewer_numbers"` FewerNumbersLockUntil time.Time `json:"fewer_numbers_lock_until"` }
type UsersClient ¶
type UsersClient struct {
// contains filtered or unexported fields
}
UsersClient is a type that implements GoatCounter Users endpoints
func (*UsersClient) Me ¶
func (c *UsersClient) Me() (*User, error)
Me is a method that implements GoatCounter /me
func (*UsersClient) URL ¶
func (c *UsersClient) URL(path string) string
Url is a method that returns the endpoint's method URL
type UsersInterface ¶
UsersInterface is an interface that defines GoatCounter Users endpoints