Documentation
¶
Index ¶
- Constants
- func NewEngine(client Client) *gin.Engine
- func NewGetRateHandler(rateService RateService, timeout time.Duration) func(*gin.Context)
- func NewServer(config config.Config, handler http.Handler) *http.Server
- func NewSubscribeUserHandler(repo UserRepository) func(*gin.Context)
- type Client
- type RateService
- type UserRepository
Constants ¶
View Source
const ( RatePath = "/rate" SubscribePath = "/subscribe" )
View Source
const RateTimeout = 3 * time.Second
Variables ¶
This section is empty.
Functions ¶
func NewGetRateHandler ¶
func NewGetRateHandler(rateService RateService, timeout time.Duration) func(*gin.Context)
NewGetRateHandler is a handler that fetches the exchange rate between USD and UAH from a RateFetcher interface and returns it as a JSON response.
func NewSubscribeUserHandler ¶
func NewSubscribeUserHandler(repo UserRepository) func(*gin.Context)
NewSubscribeUserHandler is a handler that subscribes a user by email. The email is passed as a POST parameter and is required. If the user is already subscribed, returns a 409 Conflict status code. If the subscription is successful, returns a 200 OK status code.
Types ¶
type Client ¶
type Client struct { Config config.Config RateService RateService UserRepo UserRepository }
type RateService ¶
Click to show internal directories.
Click to hide internal directories.