Refactored the application structure to better separate concerns between files and packages
Some checks failed
ci/woodpecker/push/build-image Pipeline failed

This commit is contained in:
2026-03-20 09:44:53 -05:00
parent 8deb4fd12e
commit bb18bcfb15
41 changed files with 1445 additions and 1086 deletions

View File

@@ -0,0 +1,28 @@
// observations_endpoint.go defines the /observations endpoint behavior.
// Layer: adapters/inbound/httpapi observation 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 observationDefinition(svc Service) endpoint.Definition {
return endpoint.GET(
"/observations",
bindQuery,
func(ctx context.Context, req queryRequest) (any, error) {
obs, err := svc.LatestObservation(ctx)
if err != nil {
return nil, err
}
return response.Envelope{Data: presenter.ObservationPayload(obs, req.Units)}, nil
},
endpoint.WithProduces(render.FormatJSON, render.FormatXML, render.FormatText),
endpoint.WithTemplate("observations.txt.tmpl"),
)
}