What the build checks
Suppose we change the address of an article. How do we find the links that still point to the old address? We’ll use a link from the Journal to see which mistakes the build can catch.
Start with the declaration
Start in the OpenAPI file. This is where Bwf reads the paths, parameters and response shapes for your app. Try adding a required field to a response schema. The next build will show you where a controller still constructs a response without that field.
Follow a change to the callers
Look at the link below. The view already has a slug of the type declared in OpenAPI. Give its route another required parameter and the next build will lead you back to this link. You can follow other changes the same way. Drop a column and the query that selects it needs attention. Change a component’s arguments and its callers need updating.
Here slug is already a Bend value of the type declared in OpenAPI.
<a href={url("/article/{slug}")}>{title}</a>Handle input that arrives at runtime
Now paste an address into the browser yourself. That slug arrived as text. The router has to decode it on this request, and only the application can tell whether an article exists at that address or whether you may edit it.
In this BSX fragment, raw_slug comes from the database. If conversion fails, the Journal displays the title as plain text.
converted = Api.make_ArticleSlug(raw_slug)
match converted:
case Done{slug}: <a href={url("/article/{slug}")}>{label}</a>
case Fail{_}: <span>{label}</span>Render a page or part of it
A reader can open an article in a new tab or follow a boosted link. The server supplies HTML in both cases. HTMX can limit the update to a region. Auto Refresh can render that region again after a write.
This link has an ordinary href and also works with HTMX.
<a href={url("/article/{slug}")} hx-boost="true">{title}</a>