Actions can't be completely independent of requests. For example, a request to GET /articles/123 might map a GetArticle action but it would need to know we want article 123.
Things I don't want to do:
pass an entire request object to every action
add methods to all actions that know about the request (like rails' params method, etc).
My idea is to yield a request object to the resource block in the router. That could be used to pass only the request attributes that the action needs. Something like this:
resource "article_collection", at: "/articles/:article_id" do |request|
on "GET", call: "get_article", with: request.article_id
end
Which would call (if id is 123): GetArticle.new.call(123). This lets GetArticle exist independent of an HTTP request, which is how I want actions to stay.
Actions can't be completely independent of requests. For example, a request to GET /articles/123 might map a
GetArticle
action but it would need to know we want article 123.Things I don't want to do:
params
method, etc).My idea is to yield a request object to the resource block in the router. That could be used to pass only the request attributes that the action needs. Something like this:
Which would call (if id is 123):
GetArticle.new.call(123)
. This letsGetArticle
exist independent of an HTTP request, which is how I want actions to stay.