api

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 3 Imported by: 1

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%s"
	D_DRAGON_BASE_URL_FORMAT = "https://ddragon.leagueoflegends.com%s%s"
	C_DRAGON_BASE_URL_FORMAT = "https://cdn.communitydragon.org%s%s"
)

Base API URLs formats.

Variables

View Source
var (
	ErrBadRequest = HTTPErrorResponse{
		Status: Status{
			Message:    "Bad Request",
			StatusCode: http.StatusBadRequest,
		},
	}
	ErrUnauthorized = HTTPErrorResponse{
		Status: Status{
			Message:    "Unauthorized",
			StatusCode: http.StatusUnauthorized,
		},
	}
	ErrForbidden = HTTPErrorResponse{
		Status: Status{
			Message:    "Forbidden",
			StatusCode: http.StatusForbidden,
		},
	}
	ErrNotFound = HTTPErrorResponse{
		Status: Status{
			Message:    "Not Found",
			StatusCode: http.StatusNotFound,
		},
	}
	ErrMethodNotAllowed = HTTPErrorResponse{
		Status: Status{
			Message:    "Method not allowed",
			StatusCode: http.StatusMethodNotAllowed,
		},
	}
	ErrUnsupportedMediaType = HTTPErrorResponse{
		Status: Status{
			Message:    "Unsupported media type",
			StatusCode: http.StatusUnsupportedMediaType,
		},
	}
	ErrTooManyRequests = HTTPErrorResponse{
		Status: Status{
			Message:    "Rate limited",
			StatusCode: http.StatusTooManyRequests,
		},
	}
	ErrInternalServer = HTTPErrorResponse{
		Status: Status{
			Message:    "Internal server error",
			StatusCode: http.StatusInternalServerError,
		},
	}
	ErrBadGateway = HTTPErrorResponse{
		Status: Status{
			Message:    "Bad gateway",
			StatusCode: http.StatusBadGateway,
		},
	}
	ErrServiceUnavailable = HTTPErrorResponse{
		Status: Status{
			Message:    "Service unavailable",
			StatusCode: http.StatusServiceUnavailable,
		},
	}
	ErrGatewayTimeout = HTTPErrorResponse{
		Status: Status{
			Message:    "Gateway timeout",
			StatusCode: http.StatusGatewayTimeout,
		},
	}
	StatusCodeToError = map[int]HTTPErrorResponse{
		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 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
	// Riot API Key.
	Key string
	// Maximum amount of times to retry a request on error.
	Retries int
	// Zerolog log level.
	LogLevel zerolog.Level
}

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    any
	Body     any
	Request  *http.Request
	MethodID string
	BaseURL  string
	Method   string
	Path     string
	Retries  int
	IsCDN    bool
}

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

type HTTPErrorResponse added in v0.19.0

type HTTPErrorResponse struct {
	Status Status `json:"status"`
}

func (HTTPErrorResponse) Error added in v0.19.0

func (e HTTPErrorResponse) Error() string

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"
)

type Status added in v0.3.0

type Status struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

Jump to

Keyboard shortcuts

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