class
Analyzer::CSharp::AspNetCoreMvc
- Analyzer::CSharp::AspNetCoreMvc
- Analyzer
- Reference
- Object
Included Modules
Defined in:
analyzer/analyzers/csharp/aspnet_core_mvc.crConstant Summary
-
ACCEPT_VERB_TOKENS =
["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"] of ::String -
ACCEPT_VERBS_RE =
/\[AcceptVerbs\s*\(([^\]]*)\)\s*\]/ -
[AcceptVerbs("PUT", "PATCH")]/[AcceptVerbs("PUT", Route = "Bank")]declares an action answering several verbs at one route — the MVC equivalent of stacking[HttpPut]and[HttpPatch]. It was ignored entirely, so such actions fell back to the conventional GET route. -
ACCEPT_VERBS_ROUTE_RE =
/\bRoute\s*=\s*@?"([^"]+)"/ -
DEFAULT_ROUTE =
"{controller=Home}/{action=Index}/{id?}" -
FROM_ATTRIBUTE_PATTERNS =
{"FromQuery" => "query", "FromRoute" => "path", "FromBody" => "json", "FromHeader" => "header", "FromForm" => "form", "FromCookie" => "cookie", "FromServices" => "service", "FromKeyedServices" => "service"}.map do |attr, type| {"[#{attr}", /\[#{attr}[^\]]*\]/, type} end -
Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile). The
[FromX]attribute set is fixed, so precompile its markers and strippers once at load time; the param-name regex interpolates a discovered name and is memoized. -
VERB_ATTRIBUTES =
{"[HttpPost" => {"POST", "HttpPost"}, "[HttpGet" => {"GET", "HttpGet"}, "[HttpPut" => {"PUT", "HttpPut"}, "[HttpDelete" => {"DELETE", "HttpDelete"}, "[HttpPatch" => {"PATCH", "HttpPatch"}, "[HttpHead" => {"HEAD", "HttpHead"}, "[HttpOptions" => {"OPTIONS", "HttpOptions"}} -
Attribute name carrying each verb, for
extract_attribute_route.