Goliath HttpResponse redirect

35 views
Skip to first unread message

Kenny Meyer

unread,
Feb 16, 2014, 1:09:01 PM2/16/14
to golia...@googlegroups.com
I am using Goliath + Grape and I would a resource to return a custom HTTP response. Specifically a 301 HTTP status with a Location header.

My app looks as follows:

#!/usr/bin/env ruby

require 'goliath'
require 'em-synchrony/em-http'
require 'grape'

class API < Grape::API
  version 'v1', using: :path

  resource 'isbn' do
    get "/:isbn" do
      location = "http://ww.google.com"
      [301, {}, {location: location}]
    end
  end
end

class Server < Goliath::API
  def response(env)
    API.call(env)
  end
end

This won't work, though. It returns a HTTP 200 with an XML content type.

Any hints are very welcome...

Kenny Meyer

unread,
Feb 16, 2014, 2:00:58 PM2/16/14
to golia...@googlegroups.com
Just figured it out... Grape has a helper method for that: https://github.com/intridea/grape#redirecting
Reply all
Reply to author
Forward
0 new messages