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 routes module — this generator imports routes, not types, so a config that sends the two to different directories must pass the routes one here. When non-empty the middleware imports it 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