mirror of
https://github.com/LeRoid-hub/humiditycalc.git
synced 2025-12-17 07:49: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
|
// Parse query parameters
|
||||||
tempCelsius, relativeHumidity := r.URL.Query().Get("temp"), r.URL.Query().Get("rh")
|
tempCelsius, relativeHumidity := r.URL.Query().Get("temp"), r.URL.Query().Get("rh")
|
||||||
if tempCelsius == "" || relativeHumidity == "" {
|
if tempCelsius == "" || relativeHumidity == "" {
|
||||||
|
go func(cacheW **models.WeatherCache) {
|
||||||
|
humidity, temperature := internal.Weather(env)
|
||||||
|
(*cacheW).SetData(humidity, temperature)
|
||||||
|
}(&cacheWeather)
|
||||||
tmpl.Execute(w, nil)
|
tmpl.Execute(w, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user