Thank you for reviewed members. I sent the patch.
Thanks!
Satoshi
2013/9/9 Satoshi Kobayashi <[email protected]>
> Hi,
>
> (I retransmit it because the transmission did not reach well)
>
> Currently, HTTP routing and implementation are separated. Example:
>
> ------------------------------
> class SampleApiApp(app_manager.RyuApp):
> ….
> def __init__(self, *args, **kwargs):
> ….
> wsgi = kwargs['wsgi']
> mapper = wsgi.mapper
> mapper.connect('sample', '/sample/{dpid}',
> controller=SampleController,
> action='sample_get',
> conditions=dict(method=['GET']),
> requirements={'dpid':
> dpidlib.DPID_PATTERN})
> ….
> class SampleController(ControllerBase):
> ….
> def sample_get(self, req, **_kwargs):
> ….
> ------------------------------
>
> By this design, the application needs to know the structure (method name)
> of the controller. And if the controller is changed, a change will become
> necessary for the application.
>
> Therefore I would like to propose decoration based API. Example:
>
> ------------------------------
> class SampleApiApp(app_manager.RyuApp):
> ….
> def __init__(self, *args, **kwargs):
> ….
> wsgi = kwargs['wsgi']
> wsgi.register(SampleController)
> ….
> class SampleController(ControllerBase):
>
> @route('sample', '/sample/{dpid}',
> methods=['GET'], requirements={'dpid': dpidlib.DPID_PATTERN})
> def sample_get(self, req, dpid, **_kwargs):
> ….
> ------------------------------
>
> It is not necessary to change the application even if the controller is
> changed. And readability increases because there are routing and
> implementation in the same place. Furthermore, this will conceal Routes API.
>
> This idea was inspired from Flask and Bottle of Python and JAX-RS of Java.
>
> Thanks,
> Satoshi
>
>
--
Satoshi Kobayashi <[email protected]>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel