Skip to content

Basic API can return data from the database

In order to work towards building an API that the dashboard can query for usage data, we should build an initial version of the API that can return some information from the database when queried. I propose we support a GET request against one of the tables we create.

Acceptance Criteria

  • One endpoint exists that responds to a GET request with JSON-formatted data from the database.

Security considerations

To start, the database will have only mock data; no security in place yet. Eventually, for user-facing requests, we will need to reuse users' cf authentication tokens.

Implementation sketch

  • I propose using chi, a nice minimal zero-dependency router for Go. We could also consider using the standard library, but Chi provides a nice API and middleware, and is stdlib-compatible with e.g. context.Context, net/http.Mux.