Analyzer::Groovy::Grails
Inherits Analyzer < FileHelper < Reference < Object
Grails follows a convention-over-configuration layout where each
controller class under grails-app/controllers/ exposes its action
methods as URL endpoints. The default URL mapping is
"/$controller/$action?/$id?(.$format)?", so we surface every
action method as /<controller>/<action> (the controller name is
the class name with the Controller suffix dropped and the first
letter lowercased).
Two action styles are handled:
- Method form:
def show() { ... } - Closure form:
def show = { ... }(legacy Grails)
When the controller declares
static allowedMethods = [save: 'POST', update: ['PUT', 'PATCH']]
those restrictions are honored; otherwise actions are emitted as
GET (the default Grails dispatch verb when no restriction is set).
UrlMappings.groovy is also scanned for explicit string-based mappings
of the form
get '/api/users'(controller: 'user', action: 'list')
which are surfaced as additional endpoints. It lives under
grails-app/conf/ on Grails 1.x/2.x and grails-app/controllers/ on
Grails 3+; both locations are handled. Per-verb action = [GET: ..., PUT: ...] dispatch maps and ${name} GString path variables are recognized,
while bare-status-code ("404", "500") error mappings are excluded.
Constants
One precompiled Regex.union scan (PCRE2 JIT) replaces the four OR-ed
String#includes? scans that used to gate every verbless paren-form
mapping match in emit_mapping_endpoints (runs once per match, so a
UrlMappings file with many entries repeats this often). union
auto-escapes each literal, so this is exactly equivalent to the
OR-chain it replaces.
Endpoints generated by (resources: "name") shortcuts in
UrlMappings.groovy. Each tuple is suffix appended to the base
URL plus the verb.
Actions inherited from RestfulController<T> (Grails REST base).
Actions added implicitly by static scaffold = X (Grails legacy
CRUD scaffolding).
One precompiled Regex.union scan (PCRE2 JIT) replaces the two OR-ed
String#includes? scans url_mappings_path? used to run over every
candidate path -- Crystal's includes? is not Boyer-Moore accelerated,
so a single regex pass is cheaper than two substring scans. union
auto-escapes each literal, so this is exactly equivalent to the
OR-chain it replaces.
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.