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.
#!/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
[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...