Documentation
¶
Overview ¶
Package used to share common constants and structs.
Index ¶
Constants ¶
View Source
const ( RIOT_API_BASE_URL_FORMAT = "https://%s.api.riotgames.com" D_DRAGON_BASE_URL_FORMAT = "https://ddragon.leagueoflegends.com%s" C_DRAGON_BASE_URL_FORMAT = "https://cdn.communitydragon.org%s" )
Base API URLs formats.
View Source
const ( X_RATE_LIMIT_TYPE_HEADER = "X-Rate-Limit-Type" RETRY_AFTER_HEADER = "Retry-After" )
Rate limit headers
Variables ¶
View Source
var ( ErrRetryAfterHeaderNotFound = errors.New("rate limited but no Retry-After header was found, stopping") ErrBadRequest = ErrorResponse{ Status: Status{ Message: "Bad Request", StatusCode: http.StatusBadRequest, }, } Status: Status{ Message: "Unauthorized", StatusCode: http.StatusUnauthorized, }, } ErrForbidden = ErrorResponse{ Status: Status{ Message: "Forbidden", StatusCode: http.StatusForbidden, }, } ErrNotFound = ErrorResponse{ Status: Status{ Message: "Not Found", StatusCode: http.StatusNotFound, }, } ErrMethodNotAllowed = ErrorResponse{ Status: Status{ Message: "Method not allowed", StatusCode: http.StatusMethodNotAllowed, }, } ErrUnsupportedMediaType = ErrorResponse{ Status: Status{ Message: "Unsupported media type", StatusCode: http.StatusUnsupportedMediaType, }, } ErrTooManyRequests = ErrorResponse{ Status: Status{ Message: "Rate limited", StatusCode: http.StatusTooManyRequests, }, } ErrInternalServer = ErrorResponse{ Status: Status{ Message: "Internal server error", StatusCode: http.StatusInternalServerError, }, } ErrBadGateway = ErrorResponse{ Status: Status{ Message: "Bad gateway", StatusCode: http.StatusBadGateway, }, } Status: Status{ Message: "Service unavailable", StatusCode: http.StatusServiceUnavailable, }, } ErrGatewayTimeout = ErrorResponse{ Status: Status{ Message: "Gateway timeout", StatusCode: http.StatusGatewayTimeout, }, } StatusCodeToError = map[int]ErrorResponse{ http.StatusBadRequest: ErrBadRequest, http.StatusUnauthorized: ErrUnauthorized, http.StatusForbidden: ErrForbidden, http.StatusNotFound: ErrNotFound, http.StatusMethodNotAllowed: ErrMethodNotAllowed, http.StatusUnsupportedMediaType: ErrUnsupportedMediaType, http.StatusTooManyRequests: ErrTooManyRequests, http.StatusInternalServerError: ErrInternalServer, http.StatusBadGateway: ErrBadGateway, http.StatusServiceUnavailable: ErrServiceUnavailable, http.StatusGatewayTimeout: ErrGatewayTimeout, } )
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶ added in v0.14.1
func (CacheConfig) MarshalLogObject ¶ added in v0.14.1
func (c CacheConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error
type EquinoxConfig ¶ added in v0.3.0
type EquinoxConfig struct {
// Riot API Key.
Key string
// Log level, api.NOP_LOG_LEVEL disables logging.
LogLevel LogLevel
// Timeout for the internal http.Client in seconds, 0 disables the timeout.
Timeout int
// Allows retrying a request if it returns a 429 status code.
Retry bool
// The cache used to store all GET requests done by the client.
Cache *cache.Cache
}
Configuration for the Equinox client.
func (*EquinoxConfig) MarshalLogObject ¶ added in v0.7.0
func (c *EquinoxConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error
type ErrorResponse ¶ added in v0.3.0
type ErrorResponse struct {
Status Status `json:"status"`
}
func (ErrorResponse) Error ¶ added in v0.3.0
func (e ErrorResponse) Error() string
type LogLevel ¶ added in v0.7.0
type LogLevel int8
const ( // NOP_LOG_LEVEL won't log anything, this is the default behaviour for the Default client. NOP_LOG_LEVEL LogLevel = iota - 2 // DEBUG_LOG_LEVEL will log everything. DEBUG_LOG_LEVEL // INFO_LOG_LEVEL will log the requests being made and if they were successful. INFO_LOG_LEVEL // WARN_LOG_LEVEL will log when a request was rate limited. WARN_LOG_LEVEL // ERROR_LOG_LEVEL will log every error. ERROR_LOG_LEVEL )
type PlainTextResponse ¶ added in v0.7.4
type PlainTextResponse struct {
Response any `json:"response"`
}
type RegionalRoute ¶ added in v0.17.0
type RegionalRoute string
Regional routes, used in tournament services, Legends of Runeterra (LoR), and some other endpoints.
const ( // North and South America. AMERICAS RegionalRoute = "americas" // Asia, used for LoL matches (`match-v5`) and TFT matches (`tft-match-v1`). ASIA RegionalRoute = "asia" // Europe. EUROPE RegionalRoute = "europe" // South East Asia, used for LoR, LoL matches (`match-v5`), and TFT matches (`tft-match-v1`). SEA RegionalRoute = "sea" // Asia-Pacific, deprecated, for some old matches in `lor-match-v1`. // Deprecated APAC RegionalRoute = "apac" // Special esports platform for `account-v1`. Do not confuse with the `esports` Valorant platform route. ESPORTS RegionalRoute = "esports" )
Click to show internal directories.
Click to hide internal directories.