ruby - Several optional parameters in sinatra route -


I need Sinatra route to behave in the following ways:

  received / Get 20 items with list / 20/10 offset 10 / list / 20 # get 20 items with default offset GET / list # Get default number of items with default offset  

I understand, I might pass values ​​as queries:

  get / list? Limit = 20 & offset = 10  

But I want to pass them as mentioned above, I am pretty sure what I want to do to Sinatra / Pastoron is a way to explain it, But I am currently completely trapped. I have tried:

get : list, map = & gt; '/ List' ,: with = & gt; [: Border, offset] {} Get / list at # 404: list, map = & gt; '/ List / *' {} Parameters [: Splattie]} # 404 at / Get List: List, Map = & gt; '/ List /?': Border? /?: Offset? ' {} Get / List at # 404: List, Map = & gt;

accidentally ,

  get% r {/ list (/ [^ /] +) *} two # parse parameter [: captures] end  

works It looks silly, but it looks silly.

This is the least example:

  #! / USR / bin / and rabbi are required 'get sinaatra' / exam /?: P1? /?: P2? ' "Hello # {params [: p1]}, # {params [: p2]}" end  

just / test , / exam / a and / test / A / b . Do I miss something in your question?


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -