writeonce/docs/examples/shop/product_page.controller.wo
shoney.arickathil 89df517613 feat(shop): the program template — MVC on disk; story 37 redirected
- docs/examples/shop: types.wo model, per-feature view modules
  (render() classes), root controller files, layout shell/header/
  footer, static assets controller + real style.css, README with
  Angular file map + run + DX referendum notes
- buy flow proven by hand: stock check/decrement, 409s, traversal
  404, css typed, WAL-durable; builds on the UNPATCHED toolchain
- two language gaps recorded, not fixed (per directive): pub+@table
  cannot combine (controllers forced into root module); @view
  projection classes absent
- story 37 REDIRECTED per Vue-SFC review: view.html compiled by woc
  ({{}} auto-escaped, w:if/w:for, typed against view class, no
  runtime engine); render()-as-concatenation failed the referendum;
  forks revised; shop named the acceptance consumer

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 23:57:44 +02:00

21 lines
691 B
Text

-- product_page.controller.wo — the CONTROLLER for /p/:sku.
use framework/http
use layout
use product_page
pub class ShowProduct {
pad: Int
fn handle(req: Req) -> Resp {
let sku = req.params["sku"];
if sku == nil {
return html_error(404, "No such product", "The address is missing a product.");
}
let hits = from p in Product where p.sku == sku take 1 select p;
if len(hits) == 0 {
return html_error(404, "No such product", "Nothing is listed under that sku.");
}
let p = hits[0];
let page = ProductPage { sku: p.sku, name: p.name, price: p.price, stock: p.stock };
return ok_html(app_shell("shop — ${p.name}", page.render()));
}
}