This is a sample HTTP Service, written in Typelevel Scala, which contains an endpoint that adheres to the following requirements:
- Accepts latitude and longitude coordinates.
- Returns the short forecast for that area for Today (“Partly Cloudy” etc).
- Categorizes whether the temperature is “hot”, “cold”, or “moderate”.
- Uses the National Weather Service API Web Service as a data source.
Local / target machine should have the following software installed:
jdk 21
(should work onjdk 11
or later)sbt 1.10.2
sbt compile
sbt test
To test with an external HTTP client (e.g. curl, Postman, web browser, etc):
sbt run
From command line:
curl -X GET http://localhost:8080/weather?latitude=37.7749&longitude=-122.4194
Paste the following:
http://localhost:8080/weather?latitude=37.7749&longitude=-122.4194
Successful result for those particular coordinates should yield:
{"forecast":"Mostly Cloudy","temperatureType":"cold"}
Note: these specific latitude (37.7749
) & longitude (-122.4194
) coordinates are specifically for San Francisco, California.