The DSL is a bit different than what I originally described on #64:
class PostsController < Harbor::Controller
# Runs block before any incoming request
before :all do
# ...
end
# This is a bit tricky and will call "authenticate" instance method after "/posts" requests and not before all requests as it might look to be consistent with the route definition
before :call => :authenticate
# Calls "log" instance method after any incoming PUT request
after :all, :request_method => :put, :call => :log
# Checks for authentication on all admin requests to this controller
before '/admin/*', :call => :check_authentication
# Checks for authorization before updating or creating a new post
before ':id', :request_method => [:put, :post], :call => :check_authorization
end
Done!
The DSL is a bit different than what I originally described on #64: