Deal with optional trailing slashes.
This commit is contained in:
parent
d785fae875
commit
1d6a2662c3
1 changed files with 13 additions and 1 deletions
|
@ -7,7 +7,19 @@ from api.views.radio import (AlbumViewSet, ArtistViewSet,
|
|||
GameViewSet, SongViewSet)
|
||||
|
||||
|
||||
router = DefaultRouter()
|
||||
class OptionalSlashRouter(DefaultRouter):
|
||||
'''
|
||||
Custom Router that allows for a trailing slash to be optional in the
|
||||
endpoint URI.
|
||||
|
||||
(Thanks to https://stackoverflow.com/questions/46163838/)
|
||||
'''
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.trailing_slash = '/?'
|
||||
|
||||
|
||||
router = OptionalSlashRouter()
|
||||
|
||||
router.register(r'albums', AlbumViewSet, base_name='album')
|
||||
router.register(r'artists', ArtistViewSet, base_name='artist')
|
||||
|
|
Loading…
Reference in a new issue