Ticket #442: permanent_redirect.patch

File permanent_redirect.patch, 0.7 kB (added by viktors.rotano..@gmail.com, 10 months ago)
  • lib/merb/mixins/controller.rb

    old new  
    6464    # 
    6565    # +url+ - URL to redirect to; it can be either a relative or  
    6666    # fully-qualified URL. 
     67    # +permanent+ - Whether to use permanent redirection. 
    6768    # 
    68     def redirect(url) 
    69       Merb.logger.info("Redirecting to: #{url}") 
    70       set_status(302) 
     69    def redirect(url, permanent = false) 
     70      status = permanent ? 301 : 302 
     71      Merb.logger.info("Redirecting to: #{url} status: #{status}") 
     72      set_status(status) 
    7173      headers['Location'] = url 
    7274      "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>" 
    7375    end