Documentation
¶
Overview ¶
Package unirateecho exposes the UniRate API as a set of Echo HTTP handlers.
Register wires four routes onto an *echo.Echo (or any echo.Group), each backed by a *unirate.Client:
/rate?from=USD&to=EUR /convert?from=USD&to=EUR&amount=100 /currencies /vat?country=DE (country optional; omit for all countries)
UniRate client errors are mapped to appropriate HTTP status codes and a JSON error body of the form {"error": "...", "status": <code>}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( WithTimeout = unirate.WithTimeout WithHTTPClient = unirate.WithHTTPClient WithBaseURL = unirate.WithBaseURL )
WithTimeout, WithHTTPClient and WithBaseURL are re-exported client options.
Functions ¶
func ConvertHandler ¶
func ConvertHandler(client *Client) echo.HandlerFunc
ConvertHandler returns the /convert handler.
func CurrenciesHandler ¶
func CurrenciesHandler(client *Client) echo.HandlerFunc
CurrenciesHandler returns the /currencies handler.
func RateHandler ¶
func RateHandler(client *Client) echo.HandlerFunc
RateHandler returns the /rate handler.
func VATHandler ¶
func VATHandler(client *Client) echo.HandlerFunc
VATHandler returns the /vat handler.
Types ¶
type Router ¶
type Router interface {
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
Router is the minimal Echo routing surface Register needs. Both *echo.Echo and *echo.Group satisfy it.
Click to show internal directories.
Click to hide internal directories.