Skip to content

Commit

Permalink
handle endpoints with non-string arguments in root_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
balta2ar committed Feb 17, 2022
1 parent ca4092c commit 3ae2492
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions brotab/mediator/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _setup_routes(self) -> None:
self.app.register_error_handler(TimeoutError, self.error_handler)
self.app.register_error_handler(ValueError, self.error_handler)
self.app.register_error_handler(TransportError, self.error_handler)
self.app.route('/', methods=['GET'])(self.route_index)
self.app.route('/', methods=['GET'])(self.root_handler)
self.app.route('/shutdown', methods=['GET'])(self.shutdown)
self.app.route('/list_tabs', methods=['GET'])(self.list_tabs)
self.app.route('/query_tabs/<query_info>', methods=['GET'])(self.query_tabs)
Expand All @@ -81,12 +81,12 @@ def error_handler(self, e: Exception):
self.run.shutdown(join=False)
return '<ERROR>'

def route_index(self):
def root_handler(self):
links = []
for rule in self.app.url_map.iter_rules():
args = {v: v for v in rule.arguments or {}}
url = url_for(rule.endpoint, **args)
links.append('%s\v%s' % (url, rule.endpoint))
methods = ','.join(rule.methods)
line = '{0}\t{1}\t{2}'.format(rule.endpoint, methods, rule)
links.append(line)
return '\n'.join(links)

def shutdown(self):
Expand Down

0 comments on commit 3ae2492

Please sign in to comment.