Documentation ¶
Index ¶
Constants ¶
Variables ¶
View Source
var BaseURL = url.URL{
Scheme: "https",
Host: "v2.jokeapi.dev",
}
JokeAPI base URL.
Functions ¶
This section is empty.
Types ¶
type Categories ¶
type Categories []Category
Joke categories.
func (*Categories) Add ¶
func (s *Categories) Add(c string) error
Validate and add given string as a Category. Returns an error if given string is an invalid category.
func (Categories) String ¶
func (s Categories) String() string
Convert Categories into a space-separated string.
type ErrorResponse ¶
type ErrorResponse struct { Cause []string `json:"causedBy"` Code int `json:"code"` Info string `json:"additionalInfo"` Internal bool `json:"internalError"` Message string `json:"message"` Time int `json:"timestamp"` }
An error response.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type Flags ¶
type Flags []Flag
Blacklist flags.
type IDRange ¶
A joke ID range. See https://jokeapi.dev/#idrange-param
type Joke ¶
type Joke struct { Category Category `json:"category"` Delivery string `json:"delivery"` Flags map[Flag]bool `json:"flags"` Id int `json:"id"` Joke string `json:"joke"` Lang Lang `json:"lang"` Safe bool `json:"safe"` Setup string `json:"setup"` Type Type `json:"type"` }
A single joke response from the JokeAPI "joke" endpoint.
func ParseResponse ¶
Parse given response JSON into a slice of Jokes. Returns an error if response is an error response.
type Jokes ¶
type Jokes struct {
Jokes []Joke `json:"jokes"`
}
A multi-joke response if request has Amount > 1.
type Request ¶
type Request struct { Amount int Blacklist Flags Category Categories Contains string ID *IDRange Lang Lang Safe bool Type Type }
A joke request.
func (Request) GetUsingClient ¶
Perform the HTTP GET request to fetch the joke by using the given http.Client
Click to show internal directories.
Click to hide internal directories.