Closed rantrix closed 10 years ago
For one, this will break all existing clients. What we want here is probably a way to configure the template path with a lambda
that is evaluated every time.
Btw, right now specifying rabl: "v1/user.rabl"
as an API parameter would do the trick, right?
@dblock wow, rabl: "v1/user.rabl"
is a pretty good solution to this. Though this solution did make me wonder: why make the user specify which version of the rabl to use when grape is already specifying it? Versioning is a big aspect of Grape and I think that grape-rabl should take this into consideration when it integrates grape and rabl together. What do you think?
If you have some spare time, can you please explain your suggestion of using a lambda
? I'd love to understand more. Is the env variable not being reconfigured on every request? I tried using this PR in my current rails app and it seems to be able to deliver the correct version of the rabl file based on the version that was set by the grape::api class. Thank you! =]
Because not everybody maps version to something.rabl
. You don't want to impose a directory structure on people's organization of template files that they cannot get out of.
I think I would like to be able to do:
Grape::Rabl.configure do |config|
config.tilt_root = -> { "#{env['api.version']}/..." }
end
Add the version to the template file path so that the correct version of the rabl is rendered.
With that setup, the template path will now contain the env['api.version']. If there isn't a version specified, then the original path will work fine.
I think the specs will have to include these use cases of versioning.