All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
43 lines
988 B
Markdown
43 lines
988 B
Markdown
# weatherapi
|
|
|
|
`weatherapi` is a small HTTP API that serves weather data backed by the
|
|
PostgreSQL schema populated by `weatherfeeder`.
|
|
|
|
## Config
|
|
|
|
`weatherapi` reads a YAML config file that is either:
|
|
- a top-level list of database entries, or
|
|
- an object with `databases:`.
|
|
|
|
Example:
|
|
|
|
```yaml
|
|
- name: weatherdb
|
|
driver: postgres
|
|
params:
|
|
uri: postgres://weatherdb:5432/weatherdb?sslmode=disable
|
|
username: weatherdb
|
|
password: weatherdb
|
|
```
|
|
|
|
## Endpoints
|
|
|
|
- `GET /conditions/current`
|
|
- `GET /observations?count=<1..100>&units=<us|metric>`
|
|
- `GET /forecast?timestamp=<RFC3339 timestamp>`
|
|
- `GET /alerts/current`
|
|
|
|
Default unit behavior:
|
|
- `/conditions/current`: US units
|
|
- `/observations`: metric units
|
|
- `/forecast`: US units
|
|
|
|
`/conditions/current`, `/observations`, and `/forecast` support `?units=us|metric`.
|
|
`/observations` defaults to `count=5` and validates `count` strictly in range `1..100`.
|
|
|
|
## Run
|
|
|
|
```bash
|
|
go run ./cmd/weatherapi -config ./config.yml -addr :8080
|
|
```
|