billydharmawan
1 min readMay 6, 2020

--

I will repeat: no question is dumb. :)

Okay so the application actually handles the request to OpenWeather. Think of our application as a messenger, who receives a request from us, then forwards that request to OpenWeather, and finally, delivers the response to us.

If you see the code in OpenWeatherImpl class, our application constructs the URL like so.

...
...
client
.get()
.uri { builder: UriBuilder ->
builder.path("/weather")
.queryParam("id", cityId.cityId)
.queryParam("APPID", config.apiKey)
.build()
}
...
...

That results in /weather?id=<cityId>&APPID=<config.apiKey> with the base url defined in OpenWeatherConfig class, which is https://api.openweathermap.org/data/2.5.

So, from your postman, you should send the request to http://localhost:8080/api/current-weather, which is the route defined in our Route class.

@Bean
fun buildRoute() = router {
("/api" and accept(APPLICATION_JSON)).nest {
POST("/current-weather", weatherService::getCurrentWeather)
}
}

Does that make sense?

--

--

billydharmawan
billydharmawan

Written by billydharmawan

An ordinary man trying to leave a good legacy on earth

Responses (1)