server

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHelixBaseURL = "https://api.twitch.tv"

DefaultHelixBaseURL is the default Twitch Helix API base URL.

Variables

This section is empty.

Functions

func HelixAllowlistMiddleware added in v0.7.0

func HelixAllowlistMiddleware(next http.Handler) http.Handler

HelixAllowlistMiddleware returns a middleware that checks if the request path (after stripping the /ttv prefix) is in the allowlist. Returns 403 Forbidden for non-allowlisted paths.

Types

type API

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

func New

func New(logger zerolog.Logger, config Config, client *http.Client) *API

func (*API) Launch

func (a *API) Launch(ctx context.Context) error

type CheckLinkResponse added in v0.7.0

type CheckLinkResponse struct {
	RemoteStatusCode  int
	RemoteContentType string
	VisitedURLs       []string
}

type Client

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

func NewClient

func NewClient(baseURL string, httpClient *http.Client) *Client
func (c *Client) CheckLink(ctx context.Context, targetURL string) (CheckLinkResponse, error)

func (*Client) GetChannelChatBadges added in v0.6.2

func (c *Client) GetChannelChatBadges(ctx context.Context, broadcasterID string) ([]twitchapi.BadgeSet, error)

func (*Client) GetChannelEmotes

func (c *Client) GetChannelEmotes(ctx context.Context, broadcaster string) (twitchapi.EmoteResponse, error)

func (*Client) GetChatSettings

func (c *Client) GetChatSettings(ctx context.Context, broadcasterID string, moderatorID string) (twitchapi.GetChatSettingsResponse, error)

func (*Client) GetGlobalChatBadges added in v0.6.2

func (c *Client) GetGlobalChatBadges(ctx context.Context) ([]twitchapi.BadgeSet, error)

func (*Client) GetGlobalEmotes

func (c *Client) GetGlobalEmotes(ctx context.Context) (twitchapi.EmoteResponse, error)

func (*Client) GetStreamInfo

func (c *Client) GetStreamInfo(ctx context.Context, broadcastID []string) (twitchapi.GetStreamsResponse, error)

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, logins []string, ids []string) (twitchapi.UserResponse, error)

func (*Client) RefreshToken

func (c *Client) RefreshToken(ctx context.Context, refreshToken string) (string, string, error)

func (*Client) RevokeToken added in v0.3.0

func (c *Client) RevokeToken(ctx context.Context, token string) error

type Config

type Config struct {
	ClientID             string
	ClientSecret         string
	HostAndPort          string
	RedirectURL          string
	Redis                RedisConfig
	EnableProxyRateLimit bool
}

type HelixTokenProvider added in v0.7.0

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

HelixTokenProvider manages app access tokens for the Twitch Helix API. It handles token creation and caching using the client credentials flow.

func NewHelixTokenProvider added in v0.7.0

func NewHelixTokenProvider(client *http.Client, clientID, clientSecret string) *HelixTokenProvider

NewHelixTokenProvider creates a new Helix token provider.

func (*HelixTokenProvider) EnsureToken added in v0.7.0

func (p *HelixTokenProvider) EnsureToken(ctx context.Context) (string, error)

EnsureToken returns a valid app access token, creating one if necessary. This method may perform HTTP requests to fetch a new token.

func (*HelixTokenProvider) InvalidateToken added in v0.7.0

func (p *HelixTokenProvider) InvalidateToken()

InvalidateToken clears the cached token, forcing a refresh on next GetToken call.

type RateLimiter added in v0.7.0

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

RateLimiter implements sliding window rate limiting using Redis

func NewRateLimiter added in v0.7.0

func NewRateLimiter(client *redis.Client, logger zerolog.Logger) *RateLimiter

NewRateLimiter creates a new rate limiter with Redis client. If client is nil, rate limiting is disabled.

func (*RateLimiter) Middleware added in v0.7.0

func (rl *RateLimiter) Middleware(next http.Handler) http.Handler

Middleware returns a middleware that enforces rate limits per client IP

type RedisConfig added in v0.7.0

type RedisConfig struct {
	Addr     string
	Password string
	DB       int
}

RedisConfig holds Redis connection configuration

Jump to

Keyboard shortcuts

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