Coder Social home page Coder Social logo

brunoliveiradev / weather-api-goexpertpostgrad Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

Given a valid 8-digit ZIP code, identifies the corresponding city and returns the current it's temperature in Celsius, Fahrenheit, and Kelvin.

License: Other

Go 95.91% Dockerfile 4.09%

weather-api-goexpertpostgrad's Introduction


Clima por CEP (Weather API)

Este projeto implementa uma API em Golang que recebe um CEP válido e retorna as temperaturas da localidade correspondente em Celsius, Fahrenheit e Kelvin. A API faz parte do desafio técnico do curso de Pós-Graduação em Engenharia de Software GoExpert.

⚙️ Configuração

Você precisará das seguintes tecnologias abaixo:

🚀 Iniciando

  1. Clone o repositório e entre no diretório do projeto.

    git clone https://github.com/brunoliveiradev/Weather-API-GoExpertPostGrad.git
    cd Weather-API-GoExpertPostGrad
  2. Execute o comando abaixo na pasta raiz do projeto para iniciar o ambiente de desenvolvimento:

    docker compose up --build -d

    Para parar os serviços:

    docker compose down
  3. A API estará disponível em http://localhost:8080 🚀.

🧪 Testes

  1. Para testar localmente você pode usar os cURLS de exemplo dentro do arquivo api/get_temperature.http exemplo:
    curl http://localhost:8080/01001000
  2. Resposta esperada:
     {
         "temp_C": 28.5,
         "temp_F": 83.3,
         "temp_K": 301.5
     }

🛠️ Deploy e Teste no Google Cloud Run

A aplicação já está disponível no Google Cloud Run no seguinte URL: https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app

  1. Para testar no Google Cloud Run, você pode usar o Postman e o cURL de exemplo dentro do arquivo api/get_temperature.http exemplo:
  2. Cep Válido deve retornar 200 e o JSON com as temperaturas:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/01001000
  3. Cep não encontrado deve retornar 404 com can not find zipcode:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/99999999
  4. CEP inválido deve retornar 422 com invalid zipcode:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/123456

Weather By Zipcode API

This project implements an API in Golang that receives a valid zip code and returns the temperatures of the corresponding location in Celsius, Fahrenheit and Kelvin. The API is part of the technical challenge of the Postgraduate course in Software Engineering GoExpert.

⚙️ Configuration

You will need the following technologies below:

🚀 Getting Started

  1. Clone the repository and navigate to the project directory.
    git clone https://github.com/brunoliveiradev/Weather-API-GoExpertPostGrad.git
    cd Weather-API-GoExpertPostGrad
  2. Run the command below in the project root folder to start the development environment:
     docker compose up --build -d
    To stop the services:
    docker compose down
  3. The API will be available at http://localhost:8080 🚀.
  4. To test locally you can use the example cURLS inside the api/get_temperature.http file example:
    curl http://localhost:8080/01001000

Expected response:

    {
        "temp_C": 28.5,
        "temp_F": 83.3,
        "temp_K": 301.5
    }

🛠️ Deploy and Test on Google Cloud Run

The application is already available on Google Cloud Run at the following URL: https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app

  1. To test on Google Cloud Run, you can use Postman and the example cURL inside the api/get_temperature.http file example:
  2. Valid Zipcode should return 200 and the JSON with the temperatures:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/01001000
  3. Zipcode not found should return 404 with can not find zipcode:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/89216369
  4. Invalid Zipcode should return 422 with invalid zipcode:
    curl https://weather-by-zipcode-api-4w3swr2nrq-rj.a.run.app/123456

weather-api-goexpertpostgrad's People

Contributors

brunoliveiradev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.