Skip to content

laurati/client-server-api

Repository files navigation

client-server-api

Challenge:

You will need to deliver two systems in Go:

  • client.go
  • server.go

The requirements to fulfill this challenge are:

client.go should make an HTTP request to server.go requesting the exchange rate for the dollar.

server.go should consume the API containing the exchange rate between the Dollar and Real at the following address: https://economia.awesomeapi.com.br/json/last/USD-BRL and then return the result to the client in JSON format.

Using the "context" package, server.go should record each received exchange rate in the SQLite database, with a maximum timeout of 200ms for calling the dollar exchange rate API and a maximum timeout of 10ms for persisting the data in the database.

client.go should receive only the current exchange rate value (the "bid" field of the JSON) from server.go. Using the "context" package, client.go will have a maximum timeout of 300ms to receive the result from server.go.

All three contexts should log an error if the execution time is insufficient.

client.go should save the current exchange rate in a "cotacao.txt" file in the format: Dollar: {value}.

The endpoint generated by server.go for this challenge will be: /cotacao, and the port to be used by the HTTP server will be 8080.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published