Sha256: 90451c6bdf93184904de876265438f7d6ace22f3f315fd66dc479ae08a35e0ca
Contents?: true
Size: 1.59 KB
Versions: 12
Compression:
Stored size: 1.59 KB
Contents
module Rad::Controller::Http inherit Rad::Controller::Abstract # def response # workspace.response # end protected def render_with_parsed_arguments options, original_args response = workspace.response response.set!( status: options[:status] || :ok, content_type: options[:content_type] || Mime[params.format] ) if original_args.size == 1 and (status = Rad::Http::Response.decode_status_message(original_args.first)) response.set! status: status throw :halt, "" elsif options[:location] redirect_to options[:location] else super end end module ClassMethods inheritable_accessor :actions_allowed_for_get_request, [] def allow_get_for *methods methods = methods.first if methods.first.is_a? Array enable_protection_from_get_requests! actions_allowed_for_get_request.push *(methods.collect(&:to_sym)) end private def enable_protection_from_get_requests! unless respond_to? :protect_from_get_request define_method :protect_from_get_request do request = workspace.request get = !(request.post? or request.put? or request.delete?) if get and !self.class.actions_allowed_for_get_request.include?(workspace.action) raise "GET request not allowed for :#{workspace.action} action!" end end before :protect_from_get_request end end end end
Version data entries
12 entries across 12 versions & 1 rubygems