unirategin

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 unirategin exposes the UniRate API as a set of Gin HTTP handlers.

Register wires four routes onto a *gin.Engine (or any gin.IRouter such as a route 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 Handlers

func Handlers(client *Client) (rate, convert, currencies, vat gin.HandlerFunc)

Handlers returns the four route handlers without registering them, letting callers mount them under custom paths or middleware chains.

func Register

func Register(r gin.IRouter, client *Client)

Register attaches the UniRate routes to r using client. r may be a *gin.Engine or a *gin.RouterGroup — anything satisfying gin.IRouter.

Types

type Client

type Client = unirate.Client

Client is the UniRate client type this adapter wraps. It is an alias for the underlying UniRate Go client.

func New

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

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

client := unirategin.New(os.Getenv("UNIRATE_API_KEY"))
unirategin.Register(r, client)

type Option

type Option = unirate.Option

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

Jump to

Keyboard shortcuts

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