mirror of
https://github.com/LeRoid-hub/humiditycalc.git
synced 2025-12-16 23:39:35 +00:00
cache async while the user uses the interface
This commit is contained in:
parent
baf110f9f3
commit
47c43856f1
@ -34,6 +34,10 @@ func Run(env map[string]string) {
|
||||
// Parse query parameters
|
||||
tempCelsius, relativeHumidity := r.URL.Query().Get("temp"), r.URL.Query().Get("rh")
|
||||
if tempCelsius == "" || relativeHumidity == "" {
|
||||
go func(cacheW **models.WeatherCache) {
|
||||
humidity, temperature := internal.Weather(env)
|
||||
(*cacheW).SetData(humidity, temperature)
|
||||
}(&cacheWeather)
|
||||
tmpl.Execute(w, nil)
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user