Perhaps instead of the lots of CONFIG.get('PREFIX', '') ..., it would be an idea to make a routes = [('/', index), ('/branches', list_branches), ...] list and loop over that while adding the routes?
Just one more remark: I think you can forego the %s in all of the route entries, and have the for-loop add that? If you set the routes as '', 'branches', '{branch}/pkg/{name}, ..., you could do: app.router.add_route('GET', '%s/%s' % (prefix, route[0]), route[1])
app.router.add_route('GET', '%s/%s' % (prefix, route[0]), route[1]) This won't work when prefix is '' and route[0] is '/'.
app.router.add_route('GET', '%s/%s' % (prefix, route[0]), route[1])
Right, then you would set route[0] to ''. Or you could use app.router.add_route('GET', '%s%s' % (prefix, route[0]), route[1]) with / part of the route[0]
with / part of the route[0]
That's already the case
a route[0] being '' seems to me less understandable than a '%s/'
'%s/'
Right, but the %s is still part of the route, and it's the same everywhere, so my suggestion would be to move that to the add_route part.
(Note: I am +1 to the current PR already. Just throwing some ideas out)
So what do you think of this approach then?
:thumbsup:
Let's merge then, thanks for the review! :)