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
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to