# HG changeset patch # User Marcin Kuzminski # Date 2017-01-13 16:48:05 # Node ID 1a982f31a057ad08469aaa66ac35c09623ff3b84 # Parent 0f43430bbfe0b1c9bb1c61dea28d940ccc0a7b65 http-app: use filter predicate to filter out bad backends submitted into the app. diff --git a/vcsserver/http_main.py b/vcsserver/http_main.py --- a/vcsserver/http_main.py +++ b/vcsserver/http_main.py @@ -199,7 +199,8 @@ class HTTPApplication(object): self.config.add_view(self.hg_proxy(), route_name='hg_proxy') self.config.add_view(self.git_proxy(), route_name='git_proxy') self.config.add_view( - self.vcs_view, route_name='vcs', renderer='msgpack') + self.vcs_view, route_name='vcs', renderer='msgpack', + custom_predicates=[self.is_vcs_view]) self.config.add_view(self.hg_stream(), route_name='stream_hg') self.config.add_view(self.git_stream(), route_name='stream_git') @@ -215,7 +216,6 @@ class HTTPApplication(object): self.config.add_view( self.general_error_handler, context=Exception) - def wsgi_app(self): return self.config.make_wsgi_app() @@ -351,6 +351,14 @@ class HTTPApplication(object): return app(environ, start_response) return _git_stream + def is_vcs_view(self, context, request): + """ + View predicate that returns true if given backend is supported by + defined remotes. + """ + backend = request.matchdict.get('backend') + return backend in self._remotes + def is_vcs_exception(self, context, request): """ View predicate that returns true if the context object is a VCS