Analyzer::Dart::DartFrog
Inherits Analyzer < FileHelper < Reference < Object
Dart Frog is a filesystem-routed framework. Routes live under
routes/ and the URL is derived from the directory layout:
routes/index.dart → / routes/about.dart → /about routes/users/index.dart → /users routes/users/[id].dart → /users/{id} routes/users/[id]/posts.dart → /users/{id}/posts
Each route file exports an onRequest(RequestContext, ...) handler.
Method dispatch happens inside that handler — typically a switch on
context.request.method against HttpMethod.<verb> constants. We
surface the verbs we can see referenced in the file and fall back
to the standard set when the file looks like a catch-all (no
explicit HttpMethod.* references).
_middleware.dart and other underscore-prefixed Dart files are
framework plumbing — not user-facing routes — and skipped.
Constants
Matches case HttpMethod.<verb>: clauses inside a method switch.
The handler body for a case clause runs until the next clause or
the closing brace of the switch — whichever comes first. We bound
at the earliest of a }, a case, or a default keyword so the
last enumerated method-case can't sweep in a trailing default:
arm (whose 405/methodNotAllowed would wrongly tar the case).
Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile) — precompile the fixed verb probes once at load time instead of per handler file.
A clause body that rejects the verb: methodNotAllowed,
MethodNotAllowedResponse(), or a literal 405 status code passed
positionally (Response(405)) or by name (statusCode: 405). We
deliberately avoid a bare 405 so an unrelated {'code': 405} in a
real handler body can't be mistaken for a rejection.
Every Dart Frog route file exports an onRequest handler — either a
function (Response onRequest(...), Future<Response> onRequest(...))
or the assignment form (Handler onRequest = ...). A .dart file
under a routes/ directory that lacks it is not a server route. This
matters for full-stack monorepos, where a Flutter client commonly
keeps its UI navigation under lib/.../routes/ — those widget files
must not be reported as HTTP endpoints.
Class methods
Instance methods
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.