Skip to content

Dynamically get resource's actions #8

@juscyllan

Description

@juscyllan

If I attach a resource without specifying all possible methods, the build fails.

Expected Behavior

  • Throw no errors

Actual Behavior

There was a problem expanding macro 'match'

Code in macro 'match'

 1 | match("/", ->(context : HTTP::Server::Context) { CONTROLLER.new(context).create }, via: "post", helper: false, constraints: nil, format: nil, accept: nil, content_type: nil, type: nil)
     ^
Called macro defined in lib/orion/src/orion/router/routes.cr:276:3

 276 | macro match(path, callable, *, via = :all, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil)

Which expanded to:

 > 4 |   __temp_85 = -> (context : HTTP::Server::Context) {
 > 5 |     ->(context : HTTP::Server::Context) do
 > 6 | (CONTROLLER.new(context)).create
                                 ^-----
Error: undefined method 'create' for Api::Posts

Steps to Reproduce the Problem

require "orion"
require "json"

router Router do
  resources :posts
end

class PostsController < Router::BaseController
  def index
    render text: "Hello world"
  end
end

Router.start

Specifications

  • Version:
  • Platform:
  • Subsystem:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions