Merb Router: how to return a 406 error?

This is not obvious, but it is effective. Solution: match('/',:query_string=>/. +/).

Defer_to do |request, params| raise Merb::ControllerExceptions::NotAcceptable, "Query String Unknown: #{request. Query_string}" end Explanation: In order to trigger a 406 error we need to raise Merb::ControllerExceptions::NotAcceptable but if we do this while setting up the routes it helps exactly no one. Instead we need to wait until Merb is handling the request.

This is what the defer_to block does. When the request comes in we raise the error and it is caught and handled just as it would be if we through this error from a controller. Problems One of the goals of my original question was to avoid having to go through all of the dispatching overhead.

Instead this solution is dispatched through the exceptions controller which more computationally expensive then 406,{'content-type'=>'text/plain},'406 Not Acceptable'.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions