class

Analyzer::Go::Huma

Inherits Analyzer::Go::GoEngine < Analyzer < FileHelper < Reference < Object

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.

Constants

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", "http.MethodQuery" => "QUERY"}
IMPORT_MARKER = "github.com/danielgtaylor/huma"
IMPORT_MARKER_RE = Regex.union(IMPORT_MARKER)

One precompiled matcher instead of a String#includes? scan per .go file: includes? runs Rabin-Karp over the whole buffer and the marker is absent in the overwhelming majority of files in a polyglot repo, so every one of them pays the full scan. See Analyzer#content_matches?.

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 verbose huma.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 alongside huma.Register.

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source