Proxy support for AWN/Wunderground
This commit is contained in:
@ -114,6 +114,26 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
Any("update", update).
|
||||
Msg("successfully handled update")
|
||||
w.Write([]byte("ok"))
|
||||
|
||||
// Proxy update to one or both services if configured to do so
|
||||
// Uses a weather update to allow awn to publish to wunderground and
|
||||
// visa versa.
|
||||
if station := aw.config.GetStation(update.GetStationName()); station != nil {
|
||||
if station.ProxyToAWN {
|
||||
err := aw.awnProvider.ProxyReq(ctx, update)
|
||||
if err != nil {
|
||||
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
|
||||
}
|
||||
}
|
||||
if station.ProxyToWunderground {
|
||||
err := aw.awnProvider.ProxyReq(ctx, update)
|
||||
if err != nil {
|
||||
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) InitMetrics() {
|
||||
|
Reference in New Issue
Block a user