riverqueue / riverui

A web interface for River, fast and reliable background jobs in Go.
https://ui.riverqueue.com/
Mozilla Public License 2.0
49 stars 3 forks source link

expose http.Handler, move main to cmd/riverui #26

Closed bgentry closed 2 weeks ago

bgentry commented 3 weeks ago

This extracts the main executable to cmd/riverui, and extracts the handler code to a riverui.NewHandler() function so that it can be embedded like any other http.Handler.

As part of doing this, changes were made on both the Go and JS side to facilitate running the frontend within a path prefix. Right now this is a bit messy to take advantage of because the JS frontend needs to be configured or built with the base path like so:

VITE_RIVER_API_BASE_URL=/riverui/api ./node_modules/vite/bin/vite.js build --base="/riverui/"

Additionally NewHandler() needs to be provided with the base path so that it can be stripped from incoming requests to the ServeMux.

The Dockerfile has also been reworked to make it easy to set a path prefix as well as a custom API route as desired.

Fixes https://github.com/riverqueue/riverui/issues/21.