Here is the actual code:

<?php

class My_Controller_Plugin_Rest extends Zend_Controller_Plugin_Abstract {

        /**
         * Defines the format of the REST action name
         * Quite useless atm as the dispatcher will strip
         * any non alpha character
         */

        protected $_nameFormat = ':action:method';

        /**
         * Rewrites the action according to the http method
         */

        public function preDispatch() {
                $request = $this->getRequest();
                $restActionName = $this->_translateSpec($this->_nameFormat, array(
                        'action' => $request->getActionName(),
                        'method' => $request->getMethod(),
                ));
                $request->setActionName($restActionName);
        }

        /**
         * Inject values into a spec strings
         *
         * Allowed values are:
         *      :action => the action name
         *      :method => the http method
         *
         * @param string $spec
         * @param array $vars
         * @return string
         */

        protected function _translateSpec($spec, $vars = array()) {
                foreach($vars as $key => $value) {
                        switch($key) {
                                case 'action':
                                case 'method':
                                        $$key = $value;
                                break;
                                default:
                                break;
                        }
                }

                $replacements = array(
                        ':action' => $action,
                        ':method' => $method,
                );

                $value = str_replace(array_keys($replacements), array_values($replacements),$spec);
                return $value;
        }
}

Still, i'm not completly satisfied with this plugin. Plugins certainly allows for powerful control over what's going up in the dispatch process, but the dispatcher itself enforces a set of rules on actions naming (eg, you can't have a _ in it, it is stripped at dispatch time). Thus, I'm wondering on the pertinence of writting a custom dispatcher (read My_Controller_Dispatcher_Rest) instead of just a plugin, which would enable far more possibilities.

Btw, in case you're wondering, the plugins is used like this;

$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new My_Controller_Plugin_Rest);

Easy heh ?

Also, I'm not convinced that this plugin is the way to go in matter of RESTful functionnality. I'm still wondering if it would not be better to have urls mapped to a single controller, replacing actions with http methods (that is, http://example.com/foo/bar would map to FooController::getAction, etc).

Any opinions around ?