Change view template by API version on Grape and Rails -
I am creating web APIs with grape gem on Ruby 4.1 on Rails 4.1 with my 'version' function.
Sample code here.
# app / api / api.rb class API < Grapher :: API Prefix 'API' Format: Jason Formatter: Jason, Grap :: Format :: RAL Default Format: Jason Mount V1 :: Root and #AP / API / V1 / Root. RB Module V1 Class Root & LT ; Grapes :: API version 'v1' resource: user, rabl: get "user" / / @username = user All End & End & # config / routes.rb mount API = & gt; "Code">
With these codes, I want to use the template in the
App / View / API / Users Use RL
for http: // localhost: 3000 / api / v1 / users>.
app / scene / API / V1
for the request v1
. Is there any way to do this? current
/ api / v1 / user
-> app / view / api / users.rabl
< / Li> / api / v2 / user
-> app / view / API / users Rb
like
/ api / v1 / user
-> app / view / API / V1 / users.rabl
/ api / v2 / user
-> app / view / API / V2 / users RB
I am using the grapes unit:
So I have created a directory named v1 folder called entities
ex: API / V1 / entities / token_processing_art.rbi
module example API :: V1 :: unit class token response and lieutenant; Grapes :: Busted unit: token, documentation: {type: 'string', desc: 'token string'} and end
So when I need to present I use it Required:
with current token, with: ExampleAPI :: V1 :: Entities :: TokenResponseEntity
Comments
Post a Comment