Scope nesting, but NOT resources

So I have a plug, in a pipeline attached to a scope, which checks authorization for the routes in that scope. But now, there’s 1 dang route which suddenly has to require an additional permission. Thoughts?

I’d kind of like:

scope "/foo", Bar do
  pipe_through[...]
  get ...
  get ...
  with_added_pipeline ... do
    post ...
  end
end

But I doubt that’s actually supported. I’m leaning toward a plug that actually looks at the path, and checks the additional permission, or not, based on the path. But that gets the requirement kind of far from the route, and is why I didn’t like it so much.

1 Like

How about:

scope "/foo", Bar do
  pipe_through[...]
  get ...
  get ...
  scope "/" do
    pipe_through[...more...]
    post ...
  end
end
3 Likes

Yes, OK, didn’t think of nesting a scope like that.

I do that fairly extensively. I have a folder called ‘web/routers’ that is full of routers that handle routing of the various modules built in such a way via a macro so that the helpers always end up as <module>_<module_route>_path, and the main Router just links them all in and routes properly via the URL path of /<module>/<module_paths>. :slight_smile:

1 Like