client

package
v0.0.0-...-946a516 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//BaseURL of pokeapi.co
	BaseURL string = "https://pokeapi.co/api/v2/"
	//PokemonURI of pokeapi.co
	PokemonURI string = "pokemon/"
	// DefaultClientTimeout is time to wait before cancelling the request
	DefaultClientTimeout time.Duration = 30 * time.Second
)

Variables

View Source
var CacheSettings = Settings{
	CustomExpire: 0,
	UseCache:     true,
}

CacheSettings are user settings for cache expiration.

Functions

func ClearCache

func ClearCache()

ClearCache clears all cached data.

Types

type PokeapiClient

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

PokeapiClient is the client for pokeapi

func NewPokeapiClient

func NewPokeapiClient() *PokeapiClient

NewPokeapiClient creates a new PokeapiClient

func (*PokeapiClient) FetchPokemon

func (hc *PokeapiClient) FetchPokemon(p interface{}) (model.Pokemon, error)

FetchPokemon retrieves the Resource as per provided Pokemon parameter

func (*PokeapiClient) SetTimeout

func (hc *PokeapiClient) SetTimeout(d time.Duration)

SetTimeout overrides the default ClientTimeout

type Settings

type Settings struct {
	CustomExpire time.Duration
	UseCache     bool
}

Settings is the struct that implements cache settings options

Jump to

Keyboard shortcuts

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