Add query parameter example to the README.md

This commit is contained in:
Andrew Deitrick 2014-03-20 17:28:40 -06:00
parent 8b39bbdd2d
commit 4a584f8801
1 changed files with 11 additions and 0 deletions

View File

@ -227,6 +227,17 @@ get '/posts.?:format?' do
end
```
Routes may also utilize query parameters:
``` ruby
get '/posts' do
# matches "GET /posts?title=foo&author=bar"
title = params[:title]
author = params[:author]
# uses title and author variables; query is optional to the /posts route
end
```
By the way, unless you disable the path traversal attack protection (see below),
the request path might be modified before matching against your routes.