Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e5f513088 | ||
|
|
9fcf725061 | ||
|
|
601e015f00 | ||
|
|
21fb1dff7e | ||
|
|
da924a359c | ||
|
|
a5066f15dc |
@@ -1,6 +1,6 @@
|
|||||||
from sanic.app import Sanic
|
from sanic.app import Sanic
|
||||||
from sanic.blueprints import Blueprint
|
from sanic.blueprints import Blueprint
|
||||||
|
|
||||||
__version__ = '0.4.0'
|
__version__ = '0.4.1'
|
||||||
|
|
||||||
__all__ = ['Sanic', 'Blueprint']
|
__all__ = ['Sanic', 'Blueprint']
|
||||||
|
|||||||
@@ -98,10 +98,15 @@ class Router:
|
|||||||
def add(self, uri, methods, handler, host=None):
|
def add(self, uri, methods, handler, host=None):
|
||||||
# add regular version
|
# add regular version
|
||||||
self._add(uri, methods, handler, host)
|
self._add(uri, methods, handler, host)
|
||||||
slash_is_missing = (not uri[-1].endswith('/')
|
slash_is_missing = (
|
||||||
and not self.routes_all.get(uri + '/', False))
|
not uri[-1] == '/'
|
||||||
without_slash_is_missing = (not self.routes_all.get(uri[:-1], False)
|
and not self.routes_all.get(uri + '/', False)
|
||||||
and uri is not '/')
|
)
|
||||||
|
without_slash_is_missing = (
|
||||||
|
uri[-1] == '/'
|
||||||
|
and not self.routes_all.get(uri[:-1], False)
|
||||||
|
and not uri == '/'
|
||||||
|
)
|
||||||
# add version with trailing slash
|
# add version with trailing slash
|
||||||
if slash_is_missing:
|
if slash_is_missing:
|
||||||
self._add(uri + '/', methods, handler, host)
|
self._add(uri + '/', methods, handler, host)
|
||||||
|
|||||||
19
setup.py
19
setup.py
@@ -15,6 +15,15 @@ with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
raise RuntimeError('Unable to determine version.')
|
raise RuntimeError('Unable to determine version.')
|
||||||
|
|
||||||
|
install_requires = [
|
||||||
|
'httptools>=0.0.9',
|
||||||
|
'ujson>=1.35',
|
||||||
|
'aiofiles>=0.3.0',
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.name != 'nt':
|
||||||
|
install_requires.append('uvloop>=0.5.3')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='sanic',
|
name='sanic',
|
||||||
version=version,
|
version=version,
|
||||||
@@ -22,15 +31,11 @@ setup(
|
|||||||
license='MIT',
|
license='MIT',
|
||||||
author='Channel Cat',
|
author='Channel Cat',
|
||||||
author_email='channelcat@gmail.com',
|
author_email='channelcat@gmail.com',
|
||||||
description='A microframework based on uvloop, httptools, and learnings of flask',
|
description=(
|
||||||
|
'A microframework based on uvloop, httptools, and learnings of flask'),
|
||||||
packages=['sanic'],
|
packages=['sanic'],
|
||||||
platforms='any',
|
platforms='any',
|
||||||
install_requires=[
|
install_requires=install_requires,
|
||||||
'uvloop>=0.5.3;platform_system!="Windows"',
|
|
||||||
'httptools>=0.0.9',
|
|
||||||
'ujson>=1.35',
|
|
||||||
'aiofiles>=0.3.0',
|
|
||||||
],
|
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 2 - Pre-Alpha',
|
'Development Status :: 2 - Pre-Alpha',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
|
|||||||
@@ -498,6 +498,19 @@ def test_remove_inexistent_route():
|
|||||||
with pytest.raises(RouteDoesNotExist):
|
with pytest.raises(RouteDoesNotExist):
|
||||||
app.remove_route('/test')
|
app.remove_route('/test')
|
||||||
|
|
||||||
|
def test_removing_slash():
|
||||||
|
app = Sanic(__name__)
|
||||||
|
|
||||||
|
@app.get('/rest/<resource>')
|
||||||
|
def get(_):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@app.post('/rest/<resource>')
|
||||||
|
def post(_):
|
||||||
|
pass
|
||||||
|
|
||||||
|
assert len(app.router.routes_all.keys()) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_remove_unhashable_route():
|
def test_remove_unhashable_route():
|
||||||
app = Sanic('test_remove_unhashable_route')
|
app = Sanic('test_remove_unhashable_route')
|
||||||
|
|||||||
Reference in New Issue
Block a user