How to create two routes in one block in grape?

前端 未结 2 1395
迷失自我
迷失自我 2021-01-16 01:42

I want to catch 2 similar route in one action block. In Rails5 I can do that easily. I first declare this:

get \':folder/:file\' => \'get#index\', :file =         


        
相关标签:
2条回答
  • 2021-01-16 02:11

    Example:

    desc 'Create transaction'
    params do
      requires :id, type: String
      requires :from_, type: String
    end
    post ['/:id/addresses/:from_/transactions', '/:id/transactions'] do
    
    end
    

    Routes:

    /api/v1/wallets/:id/addresses/:from_/transactions  
    /api/v1/wallets/:id/transactions
    
    0 讨论(0)
  • 2021-01-16 02:16

    Ok. I've found the answer by trying and looking to refdocs.

    get '(:folder/):file', requirements: {  folder: /.*/, file: /.*/ } do
    

    This works as expected.

    0 讨论(0)
提交回复
热议问题