Added support for rounding of values by default in API responses
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -14,13 +14,13 @@ import (
|
||||
func observationDefinition(svc Service) endpoint.Definition {
|
||||
return endpoint.GET(
|
||||
"/observations",
|
||||
bindQuery,
|
||||
func(ctx context.Context, req queryRequest) (any, error) {
|
||||
bindPrecisionQuery,
|
||||
func(ctx context.Context, req precisionQueryRequest) (any, error) {
|
||||
obs, err := svc.LatestObservation(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response.Envelope{Data: presenter.ObservationPayload(obs, req.Units)}, nil
|
||||
return response.Envelope{Data: presenter.ObservationPayload(obs, req.Units, req.Precision)}, nil
|
||||
},
|
||||
endpoint.WithProduces(render.FormatJSON, render.FormatXML, render.FormatText),
|
||||
endpoint.WithTemplate("observations.txt.tmpl"),
|
||||
|
||||
Reference in New Issue
Block a user