File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 22
33namespace georgique \yii2 \jsonrpc ;
44
5+ use Yii ;
6+ use yii \filters \ContentNegotiator ;
7+ use yii \web \Response ;
8+
9+ const JSON_RPC_ERROR_PARSE = -32700 ;
10+ const JSON_RPC_ERROR_REQUEST_INVALID = -32600 ;
11+ const JSON_RPC_ERROR_METHOD_NOT_FOUND = -32601 ;
12+ const JSON_RPC_ERROR_METHOD_PARAMS_INVALID = -32602 ;
13+ const JSON_RPC_ERROR_INTERNAL = -32603 ;
14+
515class Controller extends \yii \web \Controller {
616
717 public function actions ()
@@ -19,10 +29,23 @@ public function actions()
1929 public function behaviors ()
2030 {
2131 return [
22- 'jsonRpcFilter ' => [
23- 'class ' => JsonRpcFilter::className (),
24- ],
32+ 'contentNegotiator ' => [
33+ 'class ' => ContentNegotiator::className (),
34+ 'formats ' => [
35+ '* ' => Response::FORMAT_JSON ,
36+ ],
37+ ]
2538 ];
2639 }
2740
41+ public function beforeAction ($ action )
42+ {
43+ if ($ action == 'index ' ) {
44+ // Replace error handler, so error response is a correct JSON-RPC one
45+ Yii::$ app ->set ('errorHandler ' , ['class ' => ErrorHandler::className ()]);
46+ }
47+
48+ return true ;
49+ }
50+
2851}
You can’t perform that action at this time.
0 commit comments