Skip to content

Instantly share code, notes, and snippets.

@fronx
Created November 21, 2013 11:36
Show Gist options
  • Save fronx/7580113 to your computer and use it in GitHub Desktop.
Save fronx/7580113 to your computer and use it in GitHub Desktop.
HTTP:
GET /some/path?a=b&c=d
Sinatra, inside 'get' block:
params == {:a => 'b', :c => 'd'}
HTTP:
GET /blog/post-123?page=1
Sinatra, inside 'get' block:
params == {:page => 1}
An HTTP POST request is (usually) the result of sending a form.
In Sinatra, inside a 'post' block, params is
a representation of the form fields and values as a hashmap.
HTML form:
username: [ sheley ]
password: [ passwort ]
Sinatra:
params == {:username => 'sheley', :password => 'passwort'}
Parts of the URL can also be interpreted as parameters:
Sinatra:
get '/blog/:post' do
# GET /blog/post-123?page=1
# params == {:post => 'post-123', :page => 1}
end
@fronx
Copy link
Author

fronx commented Nov 21, 2013

@sheley Does this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment