module

Noir::CamelRouteExtractor

Apache Camel HTTP entry points, from the three route-definition languages Camel reads: the Java DSL (RouteBuilder#configure), the XML DSL and the YAML DSL. Two shapes, in each language:

  • REST DSL: rest("/users").get("/{id}").post()... — paths are relative to restConfiguration().contextPath(...), which the caller applies (it is CamelContext-wide, so usually in another file).
  • HTTP consumers: from("platform-http:/x"), from("jetty:http://h/x"), from("servlet:/x"), ... and the REST component from("rest:get:/x").

No file I/O; one FileResult per source.

Constants

CONSUMER_URI = /\A(platform-http|servlet|jetty|netty-http|undertow|rest):(.*)\z/
JAVA_DSL = "org.apache.camel"

Content gates for route files, shared by the detector and the analyzer.

METHOD_RESTRICT = /(?:\A|&)httpMethodRestrict=([^&]*)/
PARAM_TYPES = {"path" => "path", "query" => "query", "header" => "header", "body" => "json", "formData" => "form"}

Camel RestParamType -> noir param type.

URI_HOST = /\Ahttps?:\/\/[^\/]*/
VERBS = Set {"get", "post", "put", "patch", "delete", "head"}
XML_DSL = /camel\.apache\.org\/schema|<camel[\s>]/
YAML_CONTEXT_KEY = Set {"restConfiguration", "rest-configuration"}
YAML_DSL = /^-[ \t]+(?:rest|route|from|restConfiguration|rest-configuration):/m

/m: in Crystal, ^ matches only at the start of the string without it.

Instance methods

consumer_routes(uri : String, line : Int32, method_restrict : String | Nil = nil) : Array(Route)

Endpoints of one consumer URI. Non-HTTP components yield none.

Source
extract_java(source : String) : FileResult
Source
extract_xml(content : String) : FileResult
Source
extract_yaml(content : String) : FileResult
Source
http_method(raw : String | Nil) : String | Nil

Upper-cased raw when it names a real HTTP method; the generic verb(...) / <verb method> / rest: forms take any string.

Source
param_type(raw : String | Nil) : String

A declared param's noir type; Camel's RestParamType defaults to path.

Source

Nested types