Hi,

i gave a quick look at the code and it seems you need to work out the
route for "ping" on the Devices class. I'm not using reststop, but
went to check it out.

http://reststop.rubyforge.org/classes/Camping/Controllers.src/M000011.html

def no_method(e)
 _error("No controller method responds to this route!", 501, e)
end

def not_found(e)
  _error("Record not found!", 404, e)
end

Seems those 501 are being delivered by reststop.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
"10.5.2 501 Not Implemented
The server does not support the functionality required to fulfill the
request. This is the appropriate response when the server does not
recognize the request method and is not capable of supporting it for
any resource. "

In Reststop: "Calling REST "<resource name>" creates a controller with
the appropriate routes and maps your REST methods to standard Camping
controller mehods. This is meant to be used in your Controllers module
in place of R <routes>."

You'l need to specify those possible routes probably:
# GET /devices/1/ping
 def ping(id)
   ...
 end

If i well understood, you'd like to have a /devices/1/(\w+) route that
reststop could parse. It is not a case solved by a 'prefix'. If you
knew the possible methods, you'd implement them. In this case, i'd use
Camping standard Routes, where you are free to specify what you want
by the use of RegExp's.

Or... you can try to change Reststop yourself ;) on your own risk,
following or not the REST architecture :)
Start by redirecting that error message to a specific Route of yours.

/lib/reststop.rb
if e.message =~ /no such method/
 return no_method(e) # <== act here ;)
else
 raise e
end

...or even a bit above, in the protected block under send(custom_action...)

pedro mg

On 2/23/08, Albert Ng <[EMAIL PROTECTED]> wrote:
> I'm using camping with reststop to do a html front end for sending
> pre-defined messages to different devices (puts will work) depending on the
> time (will parse cron).  No real deadline.
>
> Works great up to now, much fun, forgot to sleep.
>
> Problem is when I pass a URL of the form /device/1/ping without a "Ping"
> controller method.  It will send me a "501 Not Implemented".  Interestingly
> enough, /device/1/1/ping will give me "404 Not Found" which I have properly
> handled.
>
> So my question are:
> In what part of the code can I catch the 501?
> How can I implement a catch-all controller method?
> Who's giving me the nicely formated web page when the 501's happening?
> Where could I have found that out?
>  If I stop using reststop, will the problem go away?
>
> Attached is what I have worked up till now.  Has a postamble, will work with
> webrick.
>
> _______________________________________________
>  Camping-list mailing list
>  [email protected]
>  http://rubyforge.org/mailman/listinfo/camping-list
>
>
--
pedro mg
http://blog.tquadrado.com
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to