Web responses builtins
5 builtins of Soma 3.2.4 in the category Web responses, with their exact signatures, as soma describe --builtins --json prints them.
html
html(body) -> Response | html(status: Int, body, header_key, header_value, ...) -> Responsetext/html response; auto-injects HTMX on full pages that use hx- attributes.
Used in verified programs:
- web/contact_form, line 39: {method: "GET", path: "/"} -> html("<form method='post' action='/contact'><input name='name'><input name='email'><textarea name='mes
- web/counter_api, line 52: {method: "GET", path: "/"} -> html("<h1>Counter</h1><p>POST /inc /dec /reset, GET /value</p>")
- web/guestbook, line 47: {method: "GET", path: "/"} -> html(_render())
- web/site_router, line 26: {method: "GET", path: "/"} -> html(_page("Home", "<h1>Welcome</h1><p>A site in Soma.</p>"))
response
response(status: Int, body, header_key, header_value, ...) -> ResponseResponse with explicit status, body, and optional headers.
Used in verified programs:
- services/payments_approval, line 113: if r.kind == "not_found" { return response(404, map("error", r.detail)) }
- services/warehouse_reservations, line 130: if r.kind == "not_found" { return response(404, map("error", r.detail)) }
- web/blog_tags, line 51: _ -> response(404, map("error", "no route"))
- web/contact_form, line 29: if len(errors) > 0 { return response(422, map("ok", false, "errors", errors)) }
redirect
redirect(url: String) -> Response302 redirect to url.
Used in verified programs:
- web/guestbook, line 51: redirect("/")
- web/url_shortener, line 58: if url == "" { response(404, map("error", "unknown code")) } else { redirect(url) }
sse
sse(streams...) -> ResponseOpen a Server-Sent-Events connection that receives only the named streams (no name: every stream).
publish
publish(stream: String, data) -> ()Push data to a runtime-chosen SSE stream name on the event bus.