class Analyzer::Groovy::Grails

Overview

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:

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).

grails-app/conf/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.

Defined in:

analyzer/analyzers/groovy/grails.cr

Constant Summary

DEFAULT_METHODS = ["GET"]
HTTP_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"] of ::String
RESOURCES_ENDPOINTS = [{suffix: "", method: "GET"}, {suffix: "", method: "POST"}, {suffix: "/:id", method: "GET"}, {suffix: "/:id", method: "PUT"}, {suffix: "/:id", method: "PATCH"}, {suffix: "/:id", method: "DELETE"}]

Endpoints generated by (resources: "name") shortcuts in UrlMappings.groovy. Each tuple is suffix appended to the base URL plus the verb.

RESTFUL_ACTIONS = [{name: "index", method: "GET"}, {name: "show", method: "GET"}, {name: "save", method: "POST"}, {name: "update", method: "PUT"}, {name: "patch", method: "PATCH"}, {name: "delete", method: "DELETE"}]

Actions inherited from RestfulController<T> (Grails REST base).

SCAFFOLD_ACTIONS = [{name: "index", method: "GET"}, {name: "show", method: "GET"}, {name: "create", method: "GET"}, {name: "save", method: "POST"}, {name: "edit", method: "GET"}, {name: "update", method: "PUT"}, {name: "delete", method: "DELETE"}]

Actions added implicitly by static scaffold = X (Grails legacy CRUD scaffolding).

SKIP_ACTION_NAMES = ["beforeInterceptor", "afterInterceptor", "afterView", "allowedMethods", "scaffold", "defaultAction", "errors", "response", "request", "params", "responseFormats", "namespace", "transactional"] of ::String

Instance Method Summary

Instance methods inherited from class Analyzer

analyze analyze, base_path : String base_path, base_paths : Array(String) base_paths, callees_needed? : Bool callees_needed?, logger : NoirLogger logger, parallel_analyze(channel : Channel(String), &block : String -> Nil) parallel_analyze, read_file_content(path : String) : String read_file_content, result : Array(Endpoint) result, url : String url

Constructor methods inherited from class Analyzer

new(options : Hash(String, YAML::Any)) new

Macros inherited from class Analyzer

define_getter_methods(names) define_getter_methods

Instance methods inherited from module FileHelper

all_files : Array(String) all_files, get_files_by_extension(extension : String) : Array(String) get_files_by_extension, get_files_by_prefix(prefix : String) : Array(String) get_files_by_prefix, get_files_by_prefix_and_extension(prefix : String, extension : String) : Array(String) get_files_by_prefix_and_extension, get_public_dir_files(base_path : String, folder : String) : Array(String) get_public_dir_files, get_public_files(base_path : String, anchors : Array(String) = ["shard.yml", "Gemfile"]) : Array(String) get_public_files, populate_channel_with_files(channel : Channel(String)) populate_channel_with_files, populate_channel_with_filtered_files(channel : Channel(String), extension : String)
populate_channel_with_filtered_files(channel : Channel(String), extensions : Array(String))
populate_channel_with_filtered_files

Instance Method Detail

def analyze #

[View source]