api

package
v0.0.0-...-c558d60 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attr

func Attr(n *html.Node, key string) string

func CreateCollection

func CreateCollection(db *cql.DB, r brew.Reader, collection MTGCollection) error

func DownloadCards

func DownloadCards(url, path string) error

I probably should have just kept the Makefile

func Find

func Find(n *html.Node, selector string) (*html.Node, bool)

func FindAll

func FindAll(n *html.Node, selector string) []*html.Node

func Flatten

func Flatten(n *html.Node) string

func Headers

func Headers(next goji.Handler) goji.Handler

func JSON

func JSON(w http.ResponseWriter, code int, val interface{})

func LinkHeader

func LinkHeader(host string, u *url.URL, page int) string

func MigrateDatabase

func MigrateDatabase() error

func New

func New(cfg *config.Config, client brew.Reader) http.Handler

func NotFound

func NotFound(ctx context.Context, w http.ResponseWriter, r *http.Request)

func ParseSearch

func ParseSearch(u *url.URL) (brew.Search, error, []string)

func Recover

func Recover(next goji.Handler) goji.Handler

func Slug

func Slug(name string) string

func SplitTrimSpace

func SplitTrimSpace(source, pattern string) []string

func SyncCards

func SyncCards() error

func ToSortedLower

func ToSortedLower(things []string) []string

func Tracing

func Tracing(next goji.Handler) goji.Handler

func TransformCard

func TransformCard(c MTGCard) brew.Card

func TransformCollection

func TransformCollection(collection MTGCollection) ([]brew.Set, []brew.Card)

func TransformEdition

func TransformEdition(s MTGSet, c MTGCard) brew.Edition

func TransformLegalities

func TransformLegalities(lgs []MTGLegality) map[string]string

func TransformSet

func TransformSet(s MTGSet) brew.Set

FIXME: Add released dates

Types

type API

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

func (*API) HandleCard

func (a *API) HandleCard(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleCards

func (a *API) HandleCards(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleRandomCard

func (a *API) HandleRandomCard(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleSet

func (a *API) HandleSet(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleSets

func (a *API) HandleSets(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleTerm

func (a *API) HandleTerm(f func(context.Context) ([]string, error)) func(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) HandleTypeahead

func (a *API) HandleTypeahead(ctx context.Context, w http.ResponseWriter, r *http.Request)

type ApiError

type ApiError struct {
	Errors []string `json:"errors"`
}

func Errors

func Errors(errors ...string) ApiError

type MTGCard

type MTGCard struct {
	Artist        string        `json:"artist"`
	Border        string        `json:"border"`
	Colors        []string      `json:"colors"`
	ConvertedCost float64       `json:"cmc"`
	Flavor        string        `json:"flavor"`
	HandModifier  int           `json:"hand"`
	Layout        string        `json:"layout"`
	LifeModifier  int           `json:"life"`
	Loyalty       int           `json:"loyalty"`
	Legalities    []MTGLegality `json:"legalities"`
	ManaCost      string        `json:"manaCost"`
	MultiverseId  int           `json:"multiverseid"`
	Name          string        `json:"name"`
	Names         []string      `json:"names"`
	Number        string        `json:"number"`
	Power         string        `json:"power"`
	Rarity        string        `json:"rarity"`
	Rulings       []MTGRuling   `json:"rulings"`
	Subtypes      []string      `json:"subtypes"`
	Supertypes    []string      `json:"supertypes"`
	Text          string        `json:"text"`
	Toughness     string        `json:"toughness"`
	Type          string        `json:"type"`
	Types         []string      `json:"types"`
	Watermark     string        `json:"watermark"`
}

type MTGCollection

type MTGCollection map[string]MTGSet

func LoadCollection

func LoadCollection(path string) (MTGCollection, error)

type MTGLegality

type MTGLegality struct {
	Format   string `json:"format"`
	Legality string `json:"legality"`
}

type MTGRuling

type MTGRuling struct {
	Date string `json:"date"`
	Text string `json:"text"`
}

type MTGSet

type MTGSet struct {
	Name     string    `json:"name"`
	Code     string    `json:"code"`
	Released string    `json:"releaseDate"`
	Border   string    `json:"border"`
	Type     string    `json:"type"`
	Cards    []MTGCard `json:"cards"`
}

Jump to

Keyboard shortcuts

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