module Crystal module HttpController inherit AbstractController protected def render_with_parsed_arguments options if options.content_type? workspace.response.content_type = options.content_type super elsif options.location? response = workspace.response response.location, response.status = options.location, (options.status || 301) throw :special_result, %(
You are being redirected.) elsif options.status? workspace.response.status = options.status super else super end end module ClassMethods inheritable_accessor :actions_allowed_for_get_request, [] def allow_get_for *methods enable_protection_from_get_requests! actions_allowed_for_get_request.push *methods.collect(&:to_s) end private def enable_protection_from_get_requests! unless respond_to? :protect_from_get_request define_method :protect_from_get_request do if workspace.request.get? and !self.class.actions_allowed_for_get_request.include?(workspace.action) raise "Get requests not allowed for :#{workspace.action} action!" end end before :protect_from_get_request end end end end end