// 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"), ), } }