api

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package used to share common constants and structs.

Index

Constants

View Source
const (
	RIOT_API_BASE_URL_FORMAT = ".api.riotgames.com"
	D_DRAGON_BASE_URL_FORMAT = "ddragon.leagueoflegends.com"
	C_DRAGON_BASE_URL_FORMAT = "cdn.communitydragon.org"
)

Base API URLs formats.

Variables

View Source
var (
	ErrBadRequest           = errors.New("bad request")
	ErrUnauthorized         = errors.New("unauthorized")
	ErrForbidden            = errors.New("forbidden")
	ErrNotFound             = errors.New("not found")
	ErrMethodNotAllowed     = errors.New("method not allowed")
	ErrUnsupportedMediaType = errors.New("unsupported media type")
	ErrTooManyRequests      = errors.New("too many requests")
	ErrInternalServer       = errors.New("internal server error")
	ErrBadGateway           = errors.New("bad gateway")
	ErrServiceUnavailable   = errors.New("service unavailable")
	ErrGatewayTimeout       = errors.New("gateway timeout")
)

Functions

func StatusCodeToError added in v0.10.0

func StatusCodeToError(statusCode int) error

Types

type EquinoxConfig added in v0.3.0

type EquinoxConfig struct {
	// http.Client used internally.
	HTTPClient *http.Client
	// The cache used to store all GET requests done by the client.
	Cache *cache.Cache
	// The type of rate limiter to use, only disable it if you know what you're doing.
	RateLimit *ratelimit.RateLimit
	// Riot API Key.
	Key string
	// Configuration for the logger.
	Logger Logger
	// Configuration for retries.
	Retry Retry
}

Configuration for the equinox client.

func (EquinoxConfig) MarshalZerologObject added in v0.19.0

func (c EquinoxConfig) MarshalZerologObject(encoder *zerolog.Event)

type EquinoxRequest added in v0.19.0

type EquinoxRequest struct {
	Logger   zerolog.Logger
	Route    string
	Request  *http.Request
	URL      string
	MethodID string
	IsCDN    bool
}

EquinoxRequest represents a request to the Riot API and CDNs, its a struct that contains all information about a request.

type Logger added in v1.0.0

type Logger struct {
	TimeFieldFormat string
	Level           zerolog.Level
	// Enables prettified logging
	Pretty bool
	// Prints the timestamp
	EnableTimestamp bool
	// Adds the equinox configuration to logs
	EnableConfigLogging bool
}

Logger configuration.

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-Pacific, deprecated, for some old matches in `lor-match-v1`.
	//
	// Deprecated
	APAC RegionalRoute = "apac"
	// Asia, used for LoL matches (`match-v5`) and TFT matches (`tft-match-v1`).
	ASIA RegionalRoute = "asia"
	// Special esports platform for `account-v1`. Do not confuse with the `esports` Valorant platform route.
	ESPORTS RegionalRoute = "esports"
	// Europe.
	EUROPE RegionalRoute = "europe"
	// South East Asia, used for LoR, LoL matches (`match-v5`), and TFT matches (`tft-match-v1`).
	SEA RegionalRoute = "sea"
)

func (RegionalRoute) String added in v1.0.0

func (route RegionalRoute) String() string

type Retry added in v1.0.0

type Retry struct {
	// Retries are exponential, 0 disables retries
	MaxRetries int
	// In milliseconds
	Jitter time.Duration
}

Retry configuration.

func (Retry) MarshalZerologObject added in v1.0.0

func (r Retry) MarshalZerologObject(encoder *zerolog.Event)

Jump to

Keyboard shortcuts

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