2018-03-30 02:59:51 +00:00
|
|
|
from django.urls import path
|
|
|
|
|
2018-03-28 20:12:55 +00:00
|
|
|
from rest_framework.routers import DefaultRouter
|
|
|
|
|
2018-03-30 21:22:18 +00:00
|
|
|
from api.views.controls import JustPlayed, MakeRequest, NextRequest
|
2018-04-05 20:23:01 +00:00
|
|
|
from api.views.profiles import HistoryViewSet, ProfileViewSet
|
2019-06-04 18:58:52 +00:00
|
|
|
from api.views.radio import (AlbumViewSet, ArtistViewSet, GameViewSet,
|
|
|
|
StoreViewSet, SongViewSet)
|
2018-03-28 20:12:55 +00:00
|
|
|
|
|
|
|
|
2018-04-03 20:23:17 +00:00
|
|
|
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()
|
2018-03-30 02:59:51 +00:00
|
|
|
|
2020-01-21 17:21:07 +00:00
|
|
|
router.register(r'history', HistoryViewSet, basename='history')
|
|
|
|
router.register(r'profiles', ProfileViewSet, basename='profile')
|
|
|
|
|
|
|
|
router.register(r'albums', AlbumViewSet, basename='album')
|
|
|
|
router.register(r'artists', ArtistViewSet, basename='artist')
|
|
|
|
router.register(r'games', GameViewSet, basename='game')
|
|
|
|
router.register(r'stores', StoreViewSet, basename='store')
|
|
|
|
router.register(r'songs', SongViewSet, basename='song')
|
2018-03-28 20:12:55 +00:00
|
|
|
|
2018-03-30 02:59:51 +00:00
|
|
|
urlpatterns = [
|
|
|
|
path('next/', NextRequest.as_view()),
|
|
|
|
path('played/', JustPlayed.as_view()),
|
2018-03-30 21:22:18 +00:00
|
|
|
path('request/', MakeRequest.as_view()),
|
2018-03-30 02:59:51 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
urlpatterns += router.urls
|