/// Requests and responses for the tests: what a browser or htmx sends, and /// what came back. import reply.{type Shell, Notice, Shell} import std/bytes import std/html.{type Html} import std/http.{type Request, type Response, Request} import std/list import std/option pub fn get :: path: String -> Request { Request("GET", path, [], bytes.empty ()) } pub fn post :: path: String body: String -> Request { Request( "POST" , path , [("Content-Type", "application/x-www-form-urlencoded")] , bytes.from_string body ) } pub fn htmx :: req: Request -> Request { with_header req "HX-Request" "true" } pub fn with_header :: req: Request name: String value: String -> Request { Request(..req, headers: [(name, value), ..req.headers]) } pub fn header :: resp: Response name: String -> String { list.find resp.headers fn h { h.0 == name } |> option.map fn h { h.1 } |> option.unwrap_or "" } pub fn text :: resp: Response -> String { bytes.to_string_lossy (option.unwrap_or (http.whole_body resp) (bytes.empty ())) } /// A shell that frames a page in `main`, its title as an attribute. pub fn shell :: -> Shell { Shell( framed , Notice("Not found",

nothing here

) , Notice("Bad request",

unreadable

) ) } fn framed :: title: String content: Html -> Html {
{content}
}