def test_wsgi_handler_404(self): start = mock.MagicMock() handler = wsgi.WsgiHandler() environ = self.request().environ response = handler(environ, start) self.assertEqual(response.status_code, 404) self.assertEqual(start.call_count, 1)
def setup(self, environ=None): green_pool = GreenPool() cfg = environ['pulsar.cfg'] echo_app_name = 'echo_%s' % cfg.name echo = EchoGreen(echo_app_name, green_pool.wait) app = FlaskApp(echo) return wsgi.WsgiHandler([GreenWSGI(app, green_pool)])
async def test_wsgi_handler_404(self): start = mock.MagicMock() handler = wsgi.WsgiHandler() request = await test_wsgi_request() response = await handler(request.environ, start) self.assertEqual(response.status_code, 404) self.assertEqual(start.call_count, 1)
def setup(self, environ=os.environ): app = self.getapp() middlewares = self.getmiddlemare() + [ wsgi.wait_for_body_middleware, wsgi.middleware_in_executor(app) ] return wsgi.WsgiHandler(tuple(middlewares))
def test_wsgi_handler(self): handler = wsgi.WsgiHandler() try: yield handler({}, None) except Http404: pass else: assert False
def setup(self, environ): router = HttpBin('/') return wsgi.WsgiHandler([ ExpectFail('expect'), wsgi.wait_for_body_middleware, wsgi.clean_path_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR, show_indexes=True), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self): router = HttpBin('/') return wsgi.WsgiHandler([ wsgi.clean_path_middleware, wsgi.cookies_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self, environ): '''Called once to setup the list of wsgi middleware.''' json_handler = Root().putSubHandler('calc', Calculator()) middleware = wsgi.Router('/', post=json_handler, accept_content_types=JSON_CONTENT_TYPES) response = [wsgi.GZipMiddleware(200)] return wsgi.WsgiHandler(middleware=[middleware], response_middleware=response)
def run(self, handler): from pulsar.apps import wsgi from pulsar.apps.wsgi.middleware import (middleware_in_executor, wait_for_body_middleware) # FIXME pulsar clone error, use copy wsgi_handler = wsgi.WsgiHandler( [wait_for_body_middleware, middleware_in_executor(handler)]) wsgi.WSGIServer(callable=wsgi_handler, bind="{}:{}".format(self.host, self.port)).start()
def setup(self): '''This method is called once only to setup the WSGI application handler as described in :ref:`lazy wsgi handler <wsgi-lazy-handler>` section. It creates a :ref:`publish/subscribe handler <apps-pubsub>` and subscribe it to the ``webchat`` channel.''' backend = self.cfg.get('backend_server') self.pubsub = pubsub.PubSub(backend, encoder=self.encode_message) self.pubsub.subscribe('webchat') return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home_page), ws.WebSocket('/message', Chat(self.pubsub)), wsgi.Router('/rpc', post=Rpc(self.pubsub)) ])
def setup(self, environ): '''Called once only to setup the WSGI application handler. Check :ref:`lazy wsgi handler <wsgi-lazy-handler>` section for further information. ''' cfg = environ['pulsar.cfg'] loop = environ['pulsar.connection']._loop self.store = data.create_store(cfg.data_store, loop=loop) pubsub = self.store.pubsub(protocol=WsProtocol()) channel = '%s_messages' % self.name pubsub.subscribe(channel) middleware = [wsgi.Router('/', get=self.home_page), ws.WebSocket('/message', PhilosopherWs(pubsub, channel)), wsgi.FileRouter('/favicon.ico', FAVICON), wsgi.MediaRouter('media', ASSET_DIR)] return wsgi.WsgiHandler(middleware)
def setup(self, environ): return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home), ws.WebSocket('/data', Graph(), parser_factory=self._factory), ws.WebSocket('/echo', Echo(), parser_factory=self._factory) ])
def setup(self, environ): router = Rout('/') return wsgi.WsgiHandler([router])
def handler(self): website = self.callable middleware = website.wsgi_middleware() resp_middleware = website.response_middleware() return wsgi.WsgiHandler(middleware, resp_middleware)
def setup(self, environ): return wsgi.WsgiHandler([ ws.WebSocket('/message', WsMail()), wsgi.MediaRouter('/media', ASSET_DIR), wsgi.Router('/', get=self.home) ])
def setup(self, environ=None): return wsgi.WsgiHandler( [wait_for_body_middleware, middleware_in_executor(routes.app)])
def server(): wm = ws.WebSocket('/', EchoRPC()) app = wsgi.WsgiHandler(middleware=[wm]) return wsgi.WSGIServer(callable=app)
def setup(self, environ=None): app = FlaskApp() return wsgi.WsgiHandler( (wsgi.wait_for_body_middleware, wsgi.middleware_in_executor(app)))
def setup(self, environ=None): # setup Flask logger app = routes.app() return wsgi.WsgiHandler( [wait_for_body_middleware, middleware_in_executor(app)])
def setup(self, environ): wm = ws.WebSocket('/', TitanRPC()) return wsgi.WsgiHandler(middleware=[wm], async=True)
def testWsgiHandler(self): hnd = wsgi.WsgiHandler(middleware=(wsgi.authorization_middleware,)) self.assertEqual(len(hnd.middleware), 1) hnd2 = pickle.loads(pickle.dumps(hnd)) self.assertEqual(len(hnd2.middleware), 1)
def setup(self, environ): # only post allowed by the JSON RPC handler request = [wsgi.Router('/', post=RpcRoot(self.tqname))] response = [wsgi.GZipMiddleware(200)] return wsgi.WsgiHandler(middleware=request, response_middleware=response)
def wsgi_setup(): return wsgi.WsgiHandler(middleware=[app], response_middleware=[AccessControl()])
def setup(self): return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home), ws.WebSocket('/data', Graph()), ws.WebSocket('/echo', Echo()) ])
def setup(self, environ): return wsgi.WsgiHandler([Router('/upload/')])