unirateecho

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 5 Imported by: 0

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 Register

func Register(e Router, client *Client)

Register attaches the UniRate routes to e using client.

func VATHandler

func VATHandler(client *Client) echo.HandlerFunc

VATHandler returns the /vat handler.

Types

type Client

type Client = unirate.Client

Client is the UniRate client type this adapter wraps.

func New

func New(apiKey string, opts ...Option) *Client

New constructs a UniRate Client for use with Register. Thin re-export of the underlying client's constructor so callers need only import this package.

type Option

type Option = unirate.Option

Option configures a Client (alias of the underlying client's Option).

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.

Jump to

Keyboard shortcuts

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