-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Today I was able to get riverui embedded into our system, but only after being very confused by how the endpoint for the root path works.
I thought I was doing something wrong with embedding the riverui server into my existing application. This was because I would attempt to curl http://mydev.localhost/riverui, but it would 404. Debugging showed that the handler returned to my go process was called net/http.Handler(net/http.HandlerFunc) riverqueue.com/riverui.intercept404, adding to my belief that I had got the embedding logic wrong.
However, it turns out that this was not the case. intercept404 is the name used for the handler for the / path (a utility function only used in one place). Additionally, for specifically the path that matches /, it will immediately use the fallback so as to serve the UI html. However that only happens with the correct accept headers.
This was a pretty confusing bit of code. Some things that could make this less troublesome:
- Explicitly list an endpoint for the UI separate from the static and return HTML by default.
- Use something like a 406 message if the content negotiation would fail.