Hi, Currently, HTTP Routing and implementations are separated on a WSGI application. However, I like that they are in the same place. For example, they are Flask of Python, and Bottle and JAX-RS of Java.
Then, I would like to propose the following API which based on decorator.
----------8<----------8<----------
class SampleController(ControllerBase):
@route('sample', '/sample/{dpid}',
methods=['GET'], requirements={'dpid': dpidlib.DPID_PATTERN})
def sample(self, req, dpid, **_kwargs):
return Response(status=200, body=dpid)
----------8<----------8<----------
Then, RyuApp subclass registers the controller for WSGIApplication.
----------8<----------8<----------
class NewWsgiApiApp(app_manager.RyuApp):
_CONTEXTS = {
'wsgi': WSGIApplication,
}
def __init__(self, *args, **kwargs):
super(NewWsgiApiApp, self).__init__(*args, **kwargs)
wsgi = kwargs['wsgi']
wsgi.register(SampleController)
----------8<----------8<----------
Moreover, it keeps backward compatibility.
How you do you feel about it? I have already written PoC patch and attach
to this mail.
Thanks,
Satoshi
0001-Advanced-WSGI-API.patch
Description: Binary data
------------------------------------------------------------------------------ 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=58040911&iu=/4140/ostg.clktrk
_______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
