Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CopyResponse ¶
func CopyResponse(w http.ResponseWriter, resp *ProxyResponse) error
Types ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func NewProxy ¶
func NewProxy(whoopLimiter storage.WhoopRateLimiter, rateLimitCfg RateLimitConfig) *Proxy
func (*Proxy) CheckRateLimit ¶
func (*Proxy) ProxyRequest ¶
func (p *Proxy) ProxyRequest(ctx context.Context, req *ProxyRequest) (*ProxyResponse, error)
type ProxyRequest ¶
type ProxyResponse ¶
type ProxyResponse struct {
StatusCode int
Headers http.Header
Body io.ReadCloser
}
type RateLimitConfig ¶
type RateLimitInfo ¶
type Service ¶
type Service interface {
// CheckRateLimit checks if the user can make a request.
// Returns nil if allowed.
// Returns ErrRateLimited with RateLimitInfo if rate limited.
CheckRateLimit(ctx context.Context, userID int64) (*RateLimitInfo, error)
// ProxyRequest forwards a request to the WHOOP API.
// Returns the upstream response.
// Returns ErrInvalidPath if the path is malformed.
// Returns ErrUpstreamError if the upstream request fails.
// Caller is responsible for closing ProxyResponse.Body.
ProxyRequest(ctx context.Context, req *ProxyRequest) (*ProxyResponse, error)
}
Click to show internal directories.
Click to hide internal directories.