Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CharacterBioURL = "http://stapi.co/api/v1/rest/character"
CharacterBioURL holds the STAPI API endpoint for a character bio lookup
var CharacterSearchURL = "http://stapi.co/api/v1/rest/character/search"
CharacterSearchURL holds the STAPI API endpoint for a character search
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a search querie result contains no results
Functions ¶
func NewBioMockServer ¶
func NewBioMockServer(character CharacterBioResponse) *httptest.Server
NewBioMockServer constructs a new HTTP server that responds to bio requests
func NewCharacterSearchMockServer ¶
func NewCharacterSearchMockServer(result CharacterSearchResponse) *httptest.Server
NewCharacterSearchMockServer constructs a new HTTP server that responds to bio requests
Types ¶
type Character ¶
type Character struct { UID UID `json:"uid"` Name string `json:"name"` CharacterSpecies CharacterSpecies `json:"characterSpecies"` }
Character represents a Star Trek character
func CharacterBio ¶
CharacterBio attempts to fetch additional bio information for the given character uid
func CharacterSearch ¶
CharacterSearch attempts to preform a search querie for the given character name. The first character returned inside the HTTP response is returned
type CharacterBioResponse ¶
type CharacterBioResponse struct {
Character Character `json:"character"`
}
CharacterBioResponse represents the character bio response body
type CharacterSearchResponse ¶
type CharacterSearchResponse struct {
Characters []Character `json:"characters"`
}
CharacterSearchResponse represents the character search JSON response body
type CharacterSpecies ¶
type CharacterSpecies []Species
CharacterSpecies holds possibly multiple character species for a Star Trek character
func (CharacterSpecies) String ¶
func (species CharacterSpecies) String() (result string)
String returns the character species name(s) seperated by a comma