def __call__(self, chain: HandlerChain, context: RequestContext, response: Response): try: router_response = self.router.dispatch(context.request) response.update_from(router_response) chain.stop() except NotFound: if self.respond_not_found: chain.respond(404)
def __call__( self, chain: HandlerChain, exception: Exception, context: RequestContext, response: Response, ): if not context.service: return error = self.create_exception_response(exception, context) if error: response.update_from(error)
def __call__(self, chain: HandlerChain, context: RequestContext, response: Response): try: # serve response.update_from(self.resources.dispatch(context.request)) chain.stop() except NotFound: path = context.request.path if path.startswith(constants.INTERNAL_RESOURCE_PATH + "/"): # only return 404 if we're accessing an internal resource, otherwise fall back to the other handlers LOG.warning("Unable to find resource handler for path: %s", path) chain.respond(404)
def __call__(self, chain: HandlerChain, context: RequestContext, response: Response): if not context.service: return service_name = context.service.service_name operation_name = context.operation.name key = ServiceOperation(service_name, operation_name) handler = self.handlers.get(key) if not handler: error = self.create_not_implemented_response(context) response.update_from(error) chain.stop() return handler(chain, context, response)
def __call__(self, chain: HandlerChain, context: RequestContext, response: Response): skeleton_response = self.skeleton.invoke(context) response.update_from(skeleton_response)