// The TechEmpower "fortunes" benchmark: read rows from a database, add one, // sort them and render them as an HTML table. // // This does not compile yet: it needs database access, which is not built yet, // and the `http` package has no `Server` with routes. // // Shows: an SQL query and an HTML template embedded in the same handler. use http use std::db::postgres use std::html // --------------------------------------------------------------------------- // 1. Data // --------------------------------------------------------------------------- pub struct Fortune { id: i32, message: String, } // --------------------------------------------------------------------------- // 2. The template, as a DSL // --------------------------------------------------------------------------- // The template binds immediately: `:rows` is taken from this function's scope // where the template is written, unlike a SQL placeholder. // // Every `{…}` hole is escaped, and nothing at the hole turns that off. The only // way to insert markup as it is is a value of type `html::Raw`. A hole where // the template cannot escape, such as inside `