First off, I normally only think of posting here for things specific to strictly only Crystal itself and not projects that make use of Crystal (ala Kemal) - but also I have seen others ask Kemal specific questions here. My justification beyond that is perhaps the answer is more Crystal generic and not strictly relevant to Kemal.
Apologies if this is rude to ask here.
In Rails, I can do:
get "/whatever" do
# my boring code
end
That allows me to run my boring code when someone goes to http://www.mysite.blah/whatever - very normal route.
Kemal does exactly the same - awesome, very easy, thank you.
In Rails, I can then say I want api.mysite.blah/whatever to return a JSON payload and www.mysite.blah/whatever to return the HTML payload via constraints and subdomain…
It is not obvious to me if it is possible to do that in Kemal or if there is any reason in Crystal that would prevent the equivalent functionality?
My web app can function just fine only doing it the basic way and if I really need a separate api-only domain just use a different process - but it would be convenient to handle it all via the routes. It is just not obvious to me how to do that in Kemal and I don’t see any examples close enough that make it clear to me.
And I specifically am interested in using Kemal and I don’t want a “heavier” framework like Rails - but I do like that one thing from Rails and would love to use it in Kemal/Crystal.
Any ideas or pointers?