Class: Whoosh::ClientGen::Introspector
- Inherits:
-
Object
- Object
- Whoosh::ClientGen::Introspector
- Defined in:
- lib/whoosh/client_gen/introspector.rb
Constant Summary collapse
- AUTH_PATH_PREFIX =
"/auth/"- INTERNAL_PATHS =
%w[/openapi.json /docs /redoc /metrics /healthz].freeze
- ACTION_MAP =
{ "GET" => ->(path) { path.include?("/:") || path.include?("/{") ? :show : :index }, "POST" => ->(_path) { :create }, "PUT" => ->(_path) { :update }, "PATCH" => ->(_path) { :update }, "DELETE" => ->(_path) { :destroy } }.freeze
- AUTH_ENDPOINT_MAP =
{ "login" => :login, "register" => :register, "signup" => :register, "refresh" => :refresh, "logout" => :logout, "me" => :me }.freeze
Instance Method Summary collapse
-
#initialize(app, base_url: "http://localhost:9292") ⇒ Introspector
constructor
A new instance of Introspector.
- #introspect ⇒ Object
Constructor Details
#initialize(app, base_url: "http://localhost:9292") ⇒ Introspector
Returns a new instance of Introspector.
29 30 31 32 33 |
# File 'lib/whoosh/client_gen/introspector.rb', line 29 def initialize(app, base_url: "http://localhost:9292") @app = app @base_url = base_url @router = app.instance_variable_get(:@router) end |
Instance Method Details
#introspect ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/whoosh/client_gen/introspector.rb', line 35 def introspect routes = @router.routes auth_routes, resource_routes = partition_routes(routes) auth = detect_auth(auth_routes) resources = group_resources(resource_routes) streaming = detect_streaming(resource_routes) IR::AppSpec.new( auth: auth, resources: resources, streaming: streaming, base_url: @base_url ) end |