3

My Rails 3 app is using Grape API. I know how to mount that API on a selected route mount API => '/api' but I need that api to be accessible on subdomain api.mydomain.com.

I searched Grape & Sinatra docs, questions on stack overflow and tried to google it, but I can't find any solution.

Marek Takac
  • 3,002
  • 25
  • 30

1 Answers1

6

You can use a constraints

YourAppName::Application.routes.draw do
  constraints :subdomain => "api" do
    mount API => '/'
  end
end
Sinetris
  • 8,288
  • 2
  • 22
  • 17