// ============================================================================ // 059 — Multi-Page App with Routing // ============================================================================ // Route different paths to different pages using the request handler. // // Serve: soma serve 059_multi_page.cell // Test: curl localhost:8080/ -> home page // curl localhost:8080/about -> about page // // Run: soma run 059_multi_page.cell request GET /about "" // Expect: (HTML about page) cell MultiPage { face { signal request(method: String, path: String, body: String) -> String } on request(method: String, path: String, body: String) { // Simple router based on path if path == "/about" { return html(page_layout("About", "
This is a Soma multi-page app.
Home")) } if path == "/contact" { return html(page_layout("Contact", "Email: hello@soma.dev
Home")) } // Default: home page return html(page_layout("Home", "A multi-page Soma app.
")) } // Shared layout "component" on page_layout(title: String, content: String) { return render("