Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Everything returns JSON except the track map, which is an SVG image.
| `GET /f1/next_map/` | Track map for the next race's circuit. |
| `GET /f1/tyre_usage/` | Per-driver compound and stint length for each session of the current weekend that's happened so far (FP1 through Race). Usage only, not allocation - there's no structured source anywhere for a driver's pre-weekend tyre-compound allocation, so this only reports what was actually used once a session's run. Stays on the latest weekend until the next one's first session starts, and keeps finished sessions in memory since OpenF1's free tier locks out all access while any session is live. |
| `GET /f1/latest_session/` | Classification of the most recently finished non-race session of the current weekend (practice, sprint qualifying, qualifying or sprint) - best lap for the leader, gap for everyone else. The Grand Prix itself is `/f1/last_race/`. Sourced from OpenF1, so it shares its live-session lockout (finished sessions are kept in memory once fetched). |
| `GET /healthz` | Liveness probe - always `200 {"status":"ok"}` while the process serves HTTP; never calls upstream APIs. |

# Development
Requires Go 1.26+.
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func newServer(a *app) *echo.Echo {
e.GET(route.path, route.handler)
e.GET(route.path+"/", route.handler)
}
// Liveness only - never touches upstream APIs, so an Ergast/OpenF1 outage doesn't restart the pod.
e.GET("/healthz", func(c echo.Context) error { return c.JSON(http.StatusOK, map[string]string{"status": "ok"}) })
return e
}

Expand Down
7 changes: 7 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func TestDriversContractAndCache(t *testing.T) {
}
}

func TestHealthz(t *testing.T) {
mock := newUpstreamMock(t)
if result := decode(t, request(t, newServer(testApp(t, mock)), "/healthz")); result["status"] != "ok" || len(mock.hits) != 0 {
t.Fatalf("unexpected response %#v, upstream hits %v", result, mock.hits)
}
}

func TestConstructorsContract(t *testing.T) {
mock := newUpstreamMock(t)
result := decode(t, request(t, newServer(testApp(t, mock)), "/f1/constructors_standings/"))
Expand Down
Loading