Added wind route and started forecast endpoint

This commit is contained in:
2025-06-17 17:38:31 +02:00
parent cbafd785b9
commit 9e419ec7bf
9 changed files with 378 additions and 18 deletions

View File

@@ -6,7 +6,7 @@ import (
// CacheType, representing the abstract value of a CacheEntity
type CacheType interface {
Weather | Metrics
Weather | Metrics | Wind | Forecast
}
// CacheEntity, representing the value of the cache
@@ -22,14 +22,18 @@ type Cache[T CacheType] struct {
// Caches, representing a grouping of the various caches
type Caches struct {
WeatherCache Cache[Weather]
MetricsCache Cache[Metrics]
WeatherCache Cache[Weather]
MetricsCache Cache[Metrics]
WindCache Cache[Wind]
ForecastCache Cache[Forecast]
}
func InitCache() *Caches {
return &Caches{
WeatherCache: Cache[Weather]{Data: make(map[string]CacheEntity[Weather])},
MetricsCache: Cache[Metrics]{Data: make(map[string]CacheEntity[Metrics])},
WeatherCache: Cache[Weather]{Data: make(map[string]CacheEntity[Weather])},
MetricsCache: Cache[Metrics]{Data: make(map[string]CacheEntity[Metrics])},
WindCache: Cache[Wind]{Data: make(map[string]CacheEntity[Wind])},
ForecastCache: Cache[Forecast]{Data: make(map[string]CacheEntity[Forecast])},
}
}

19
types/forecast.go Normal file
View File

@@ -0,0 +1,19 @@
package types
// The ForecastEntity data type, representing the weather forecast
// of a single day
type ForecastEntity struct {
Date *ZephyrDate `json:"date"`
Min string `json:"min"`
Max string `json:"max"`
Condition string `json:"condition"`
Emoji string `json:"emoji"`
FeelsLike string `json:"feelsLike"`
Wind Wind `json:"wind"`
}
// The Forecast data type, representing the an set
// of ForecastEntity
type Forecast struct {
Forecast []ForecastEntity
}

View File

@@ -1,6 +1,6 @@
package types
// The Weather data type, representing the weather of a certain city
// The Weather data type, representing the weather of a certain location
type Weather struct {
Date *ZephyrDate `json:"date"`
Temperature string `json:"temperature"`

8
types/wind.go Normal file
View File

@@ -0,0 +1,8 @@
package types
// The Wind data type, representing the wind of a certain location
type Wind struct {
Arrow string `json:"arrow"`
Direction string `json:"direction"`
Speed string `json:"speed"`
}