context switch - Zend Framework 1.12 and 'ContextSwitch' helper -


i'm writing rest api , return responses in json format. so, read about 'contextswitch'. can't make change headers 'application/json' , convert data json.

here code of controller:

 public function predispatch() {      $this->getrequest()->setparam('format', 'json');     $this->_helper->layout()->disablelayout();     $this->_helper->viewrenderer->setnorender(true); }   public function _init() {      $contextswitch = $this->_helper->gethelper('contextswitch');     $contextswitch ->addactioncontext('post', 'json')                     ->initcontext('json'); }  public function postaction() {     echo 'test';  } 

when check response curl command line tool received:

< content-length: 4 < content-type: text/html <  * connection #0 host localhost left intact test* closing connection #0 

why header , data not changed? how can fix it?

looks _init() method not executed @ all. try renaming init().


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -