Merge pull request #756 from dz0ny/fix/static_router_constructor
Fix http router so it can handle /{ext_name} same as /{ext_name}/
This commit is contained in:
commit
490c7a02b7
@ -96,14 +96,14 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
result = []
|
result = []
|
||||||
for static in self.statics:
|
for static in self.statics:
|
||||||
result.append((
|
result.append((
|
||||||
r'/%s/(.*)' % static['name'],
|
r'/{}/?(.*)'.format(static['name']),
|
||||||
handlers.StaticFileHandler,
|
handlers.StaticFileHandler,
|
||||||
{
|
{
|
||||||
'path': static['path'],
|
'path': static['path'],
|
||||||
'default_filename': 'index.html'
|
'default_filename': 'index.html'
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
logger.debug('Loaded HTTP extension: %s', static['name'])
|
logger.debug('Loaded static HTTP extension: %s', static['name'])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _publish_zeroconf(self):
|
def _publish_zeroconf(self):
|
||||||
|
|||||||
@ -23,7 +23,7 @@ def mopidy_app_factory(config, core):
|
|||||||
(r'/rpc', JsonRpcHandler, {
|
(r'/rpc', JsonRpcHandler, {
|
||||||
'core': core,
|
'core': core,
|
||||||
}),
|
}),
|
||||||
(r'/(.*)', StaticFileHandler, {
|
(r'/?(.*)', StaticFileHandler, {
|
||||||
'path': os.path.join(os.path.dirname(__file__), 'data'),
|
'path': os.path.join(os.path.dirname(__file__), 'data'),
|
||||||
'default_filename': 'mopidy.html'
|
'default_filename': 'mopidy.html'
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -53,6 +53,16 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase):
|
|||||||
response.headers['X-Mopidy-Version'], mopidy.__version__)
|
response.headers['X-Mopidy-Version'], mopidy.__version__)
|
||||||
self.assertEqual(response.headers['Cache-Control'], 'no-cache')
|
self.assertEqual(response.headers['Cache-Control'], 'no-cache')
|
||||||
|
|
||||||
|
def test_mopidy_should_return_index_no_slash(self):
|
||||||
|
response = self.fetch('/mopidy', method='GET')
|
||||||
|
|
||||||
|
self.assertIn(
|
||||||
|
'Here you can see events arriving from Mopidy in real time:',
|
||||||
|
tornado.escape.to_unicode(response.body))
|
||||||
|
self.assertEqual(
|
||||||
|
response.headers['X-Mopidy-Version'], mopidy.__version__)
|
||||||
|
self.assertEqual(response.headers['Cache-Control'], 'no-cache')
|
||||||
|
|
||||||
def test_should_return_js(self):
|
def test_should_return_js(self):
|
||||||
response = self.fetch('/mopidy/mopidy.js', method='GET')
|
response = self.fetch('/mopidy/mopidy.js', method='GET')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user