/VaporWeatherServer

Async/Await in Vapor

Primary LanguageSwiftGNU General Public License v3.0GPL-3.0

Weather API with Server-Side Swift

This is a demo server created for the article "Async/Await in Vapor — How to create a weather API with Server-Side Swift"

You are going to discover how to fetch the weather from OpenWeatherMap (abbreviated to OWM). The goal is to learn how to design and create an API Endpoint that needs to execute some tasks before returning the result to the client. It can be achieved easily with the new async/await operators.

The final application will make two parallel requests to OWM to get detailed weather data, combine the results and return it to the client.

Of course, OpenWeatherMap already has an API Endpoint (One Call) that gives all those information but as said before, the goal of this article is to learn how to work with concurrency with Vapor.

Final Result

http://127.0.0.1:8080/weather?lat=40.851799&lon=14.268120

http://127.0.0.1:8080/weather?lat=40.851799&lon=14.268120