nori/codegen/gleam_routes
Generates server-side route matching as string output.
Produces a Gleam module with a Route union type and a match_route function that pattern-matches HTTP method + path segments.
Values
pub fn generate(
ir: ir.CodegenIR,
module_prefix: String,
) -> String
Generates a complete Gleam routes module string from the CodegenIR.
module_prefix is the Gleam module path of the types module (e.g.
"generated" for ./src/generated, or "shared/generated" when the config
splits the output across projects). When non-empty it’s used to emit real
imports; when empty a comment hint is produced instead.
pub fn query_enum_names(
ir: ir.CodegenIR,
module_prefix: String,
) -> List(String)
Enum type names usable in a query record.
⚠️ Enums only. A record-typed query parameter has no from_string, so naming
its type here would emit a call that was never generated; those stay String.
Empty when there is no types import to reference (module_prefix empty),
because the names would not resolve.
pub fn query_enum_of(
p: ir.EndpointParam,
enums: List(String),
) -> option.Option(String)
pub fn query_field_names(ep: ir.Endpoint) -> naming.ParamNames
The query record’s labels. Shared with the MCP generator, which builds the same record.
pub fn query_params(ep: ir.Endpoint) -> List(ir.EndpointParam)
pub fn query_record_name(ep: ir.Endpoint) -> String
pub fn to_pascal_case(name: String) -> String
Convert a name to PascalCase. See naming.to_pascal_case.
pub fn to_snake_case(name: String) -> String
Convert a name to snake_case. See naming.to_snake_case.