class
Analyzer::Go::Huma
- Analyzer::Go::Huma
- Analyzer::Go::GoEngine
- Analyzer
- Reference
- Object
Overview
Huma (https://huma.rocks/) is an OpenAPI-first Go framework
where every operation is registered through
huma.Register(api, huma.Operation{Method: ..., Path: ...}, handler)
The Operation literal carries method/path verbatim, and the
handler's Input struct fields declare parameter shape via
tags (path:"id", query:"limit", header:"X-Auth", plus
a Body field for request bodies). That makes extraction
unusually precise compared to other Go routers.
Defined in:
analyzer/analyzers/go/huma.crConstant Summary
-
HTTP_METHOD_CONSTANTS =
{"http.MethodGet" => "GET", "http.MethodPost" => "POST", "http.MethodPut" => "PUT", "http.MethodPatch" => "PATCH", "http.MethodDelete" => "DELETE", "http.MethodHead" => "HEAD", "http.MethodOptions" => "OPTIONS", "http.MethodConnect" => "CONNECT", "http.MethodTrace" => "TRACE"} -
IMPORT_MARKER =
"github.com/danielgtaylor/huma" -
PARAM_TAG_KINDS =
{"path" => "path", "query" => "query", "header" => "header", "cookie" => "cookie"} -
Tags we lift from Input struct fields onto endpoint params.
-
PARAM_TAG_PATTERNS =
PARAM_TAG_KINDS.map do |go_tag, param_type| {param_type, /#{go_tag}:"([^"]+)"/} end -
Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile) — precompile the fixed tag matchers once at load time instead of per struct field.
-
SUGAR_VERBS =
{"huma.Get" => "GET", "huma.Post" => "POST", "huma.Put" => "PUT", "huma.Patch" => "PATCH", "huma.Delete" => "DELETE", "huma.Head" => "HEAD", "huma.Options" => "OPTIONS"} -
Huma v2's typed convenience helpers —
huma.Get(api, "/path", handler)and friends — register an operation without the verbosehuma.Register(api, huma.Operation{...}, handler)literal. The verb is the method name; the path is the SECOND argument (the first is the API/group). Mapped here so the call walker can decode them alongsidehuma.Register.