Also, when "remove slash and redirect" (in the "Middleware"), use a 301 status.
This is well recognized by browsers, and leads to a request to the respective
resource (in contrast to 308. 308 may be useful for other HTTP methods than GET,
but our entire redirect middleware only handles GET and HEAD anyways (POST are
excluded).
Cstruct.copy is deprecated
Mirage_crypto_rng_unix.initialize requires the RNG module as paramater (since mirage-crypto-rng 0.11.0)
Lwt_result.catch takes a function (unit -> 'a Lwt.t) since lwt 5.7.0
- Only hook scripts that end in .sh are executed.
- When packaging for FreeBSD, batch-viz.sh and visualizations.sh are
installed with a .sample extension. Addresses #137
In the View.compare_builds (/compare/..), do not display
"XX opam packages unchanged".
The reasoning is that the diff view concerns:
(a) opam packages
(b) environment variables
(c) system packages
And we're only interested in what changed in each category. The list of
unchanged opam packages is not really of interest, but adds quite some noise to
the page.
It is not immediately obvious how to avoid the error handler making a
different 404 response when the application code returns an explicit 404
page. Since we were already replying "Resource not found" in all cases
except one where we reply "File not found" not much is lost by relying
on the error handler behavior.
- Dream.path is deprecated. For now the deprecation is suppressed.
- Remove unused dream_svg.
- Remove datadir global. The datadir variable is in scope already, and
global variables were removed in alpha3.
- Dream_tar.tar_response: flush before closing. It's unclear if this is
necessary.
- Change Builder_web.add_routes to Builder_web.routes returning a list
of routes, and in Builder_web_app construct the router.
- Builder_web.not_found is removed due to changes in Dream.router. It
seems an error handler might be the way forward.
This PR solves the issue of there being both "<url>/" and "<url>" paths, that in the builder-web context shouldn't mean different things.
The slashes are now removed using a `Dream` middleware, and the request is redirected using a permanent redirect (that doesn't change the method used): https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location
Notable changes:
* Trailing slashes from the hardcoded link urls were removed, as unneccesary redirects are then avoided.
* All links in `Views` were rewritten to be absolute instead of relative.
* As `Dream` deprecated `path` - `Utils.Path` was created containing some helpers for manipulating paths. *Note that `String.split_on_char` has a different semantics.*
* A blacklist `routeprefix_blacklist_when_removing_trailing_slash` was added, containing `Dream` route-prefixes to ignore.
* Only `GET` and `HEAD` requests are redirected.
* `redirect_parent` helper was rewritten using new `Utils.Path` functions to avoid brittle string manipulation + fixed the edgecase of redirecting to `/`.
* Added `Uri` dependency to make URL manipulation safer.
Co-authored-by: rand00 <oth.rand@gmail.com>
Co-authored-by: Reynir Björnsson <reynir@reynir.dk>
Reviewed-on: https://git.robur.io/robur/builder-web/pulls/80
Co-authored-by: rand <rand@r7p5.earth>
Co-committed-by: rand <rand@r7p5.earth>