Rovak / KJSencha

Ext-JS / Sencha Touch Integration Module for Zend Framework 2
Other
24 stars 15 forks source link

Move decoding of RPC requests to a custom HTTP Route #5

Open Ocramius opened 11 years ago

Ocramius commented 11 years ago

Current status

Logic used to parse parameters within an RPC HTTP request coming from ExtJs is currently located in KJSencha\Controller\DirectController#getRPC().

Proposal

This logic can be decomposed into a simple Zend\Mvc\Router\Http\RouterInterface that will be able to accept requests and produce standard controller and action parameters, along with an RPC object stored in the returned RouteMatch.

This unlocks a set of interesting features:

  1. can add guards at route level (security)
  2. allows usage of standard controller and action parameters in MVC
  3. allows usage of standard controllers in RPC context
  4. can use the mapper service to already avoid matching on non-mapped services (404 instead of 5xx error)
  5. can use guards at dispatch level (since we'll have the actionparameter, this is important if we need to integrate with tools like BjyAuthorize)

    Problems

If the controller key is already valued DirectController by the router, we cannot use it for route guards. Same applies for action. We can anyway integrate with our own Route or Controller Guard assuming the end user is using BjyAuthorize. We can then trigger any checks on the Route or Controller guard with our custom parameters.