strava

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: ISC Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsStravaError

func AsStravaError(err error, target **StravaError) bool

AsStravaError checks if an error is a StravaError and assigns it to the target.

Types

type Client

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

Client is the Strava API HTTP client with automatic token refresh.

func NewClient

func NewClient(cfg *config.Config, store auth.TokenStore, logger *slog.Logger) *Client

NewClient creates a new Strava API client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, params map[string]string) ([]byte, error)

Get makes an authenticated GET request to the Strava API.

func (*Client) GetRateLimits

func (c *Client) GetRateLimits() RateLimits

GetRateLimits returns the current rate limit state.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}) ([]byte, error)

Post makes an authenticated POST request to the Strava API.

func (*Client) PostMultipart

func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) ([]byte, error)

PostMultipart makes an authenticated POST request with a pre-built multipart body. The contentType must include the multipart boundary (use writer.FormDataContentType()).

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body interface{}) ([]byte, error)

Put makes an authenticated PUT request to the Strava API.

func (*Client) RateLimitWarning

func (c *Client) RateLimitWarning() string

RateLimitWarning returns a warning string if rate limit usage exceeds 80%. Returns empty string when usage is within acceptable limits.

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(u string)

SetBaseURL overrides the API base URL (for testing).

func (*Client) SetTokenURL

func (c *Client) SetTokenURL(u string)

SetTokenURL overrides the token refresh URL (for testing).

type RateLimits

type RateLimits struct {
	Limit15Min int
	LimitDaily int
	Usage15Min int
	UsageDaily int
}

RateLimits holds the current Strava API rate limit state.

type StravaError

type StravaError struct {
	StatusCode int
	Body       string
}

StravaError represents an error response from the Strava API.

func (*StravaError) Error

func (e *StravaError) Error() string

Jump to

Keyboard shortcuts

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