nori/codegen/gleam_middleware

Generates server-side middleware for Gleam from the OpenAPI IR.

Produces a Gleam module with auth extractors, route-level auth checks, composable middleware builders, request validation, and CORS handling. Generated based on security schemes defined in the OpenAPI specification.

Values

pub fn generate(
  ir: ir.CodegenIR,
  module_prefix: String,
) -> String

Generates a complete Gleam middleware module string from the CodegenIR.

module_prefix is the Gleam module path of the generated output directory (e.g. "generated" for ./src/generated). When non-empty the middleware imports the consumer’s routes module so is_public_route can match on Route variants directly. When empty the function is emitted commented out with a hint, matching the pre-prefix behavior.

Search Document