Implemented weather stories support
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful

This commit is contained in:
2026-05-30 07:06:29 -05:00
parent bde515d146
commit ecea856e8e
18 changed files with 760 additions and 4 deletions

View File

@@ -0,0 +1,43 @@
// weatherstories_endpoint.go defines the /weatherstories endpoint behavior.
// Layer: adapters/inbound/httpapi weather stories route.
package httpapi
import (
"context"
"gitea.maximumdirect.net/ejr/feedapi/endpoint"
"gitea.maximumdirect.net/ejr/feedapi/render"
"gitea.maximumdirect.net/ejr/feedapi/response"
"gitea.maximumdirect.net/ejr/weatherapi/internal/adapters/inbound/httpapi/presenter"
)
func weatherStoriesDefinitions(svc Service) []endpoint.Definition {
return []endpoint.Definition{
endpoint.GET(
"/weatherstories",
bindTimezoneQuery,
func(ctx context.Context, req timezoneQueryRequest) (any, error) {
run, err := svc.LatestWeatherStoryRun(ctx)
if err != nil {
return nil, err
}
return response.Envelope{Data: presenter.WeatherStoryRunPayload(run, req.Units, req.Timezone)}, nil
},
endpoint.WithProduces(render.FormatJSON, render.FormatXML, render.FormatText),
endpoint.WithTemplate("weatherstories.txt.tmpl"),
),
endpoint.GET(
"/weatherstories/latest",
bindTimezoneQuery,
func(ctx context.Context, req timezoneQueryRequest) (any, error) {
story, err := svc.LatestWeatherStory(ctx)
if err != nil {
return nil, err
}
return response.Envelope{Data: presenter.WeatherStoryPayload(story, req.Units, req.Timezone)}, nil
},
endpoint.WithProduces(render.FormatJSON, render.FormatXML, render.FormatText),
endpoint.WithTemplate("weatherstories_latest.txt.tmpl"),
),
}
}