I'm trying to get the simple put and get running. Get works perfectly but I seem to get a 404 with a PUT.
Things I've tried:
- Wrote up code for a app.get "/users/:id" and localhost:3000/users/400 to print the user's id on the browser -> this works and it's a get
- Tried doing the same for a post -> app.post "/users/add" (code below) and did a "localhost:3000/users/add/11" but I get a 404.
My doubts:
- How can I test the post on a browser? How should the URL be? Where can I put info to be posted in the URL? Or should it not be specified in the URL? (This is confusing) I am guessing the lack of input data is giving me a 404.
I run this on the Sinatra framework and this what I see on the console:
INFO WEBrick::HTTPServer#start: pid=10137 port=3000 ::1 - - [19/Mar/2015:11:36:34 -0700] "GET /users/add HTTP/1.1" 403 - 0.0156
(Wait, shouldn't this be a POST??)
::1 - - [19/Mar/2015:11:36:45 -0700] "GET /users/add/11 HTTP/1.1" 404 688 0.0086
(My question on how I specify the data to be put)
::1 - - [19/Mar/2015:11:43:15 -0700] "GET /users/add/name=11 HTTP/1.1" 404 693 0.0018
My routes users.rb code:
module Routes
module Users
def self.registered(app)
app.post '/users/add' do
reqUserId = params[:id]
"params id #{reqUserId}"
end
end
end
Any help would be great. I'm super open to reading anything too.