refactor. pre-deploy
This commit is contained in:
44
.history/backend/api/urls_20251029201838.py
Normal file
44
.history/backend/api/urls_20251029201838.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from django.urls import path
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
||||
from .views import (
|
||||
RegisterView,
|
||||
UserProfileView,
|
||||
LinkViewSet,
|
||||
LinkGroupViewSet,
|
||||
PublicUserGroupsView
|
||||
)
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
||||
|
||||
class NoTrailingSlashRouter(DefaultRouter):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.trailing_slash = '/?'
|
||||
|
||||
router = NoTrailingSlashRouter()
|
||||
router.register('links', LinkViewSet, basename='link')
|
||||
router.register('groups', LinkGroupViewSet, basename='group')
|
||||
|
||||
urlpatterns = [
|
||||
path('auth/register/', RegisterView.as_view(), name='auth_register'),
|
||||
path('auth/register', RegisterView.as_view(), name='auth_register_no_slash'),
|
||||
path('auth/login/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
path('auth/login', TokenObtainPairView.as_view(), name='token_obtain_pair_no_slash'),
|
||||
path('auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
path('auth/refresh', TokenRefreshView.as_view(), name='token_refresh_no_slash'),
|
||||
path('auth/user/', UserProfileView.as_view(), name='user-profile'), # ← новый
|
||||
path('auth/user', UserProfileView.as_view(), name='user-profile-no-slash'),
|
||||
path('users/<str:username>/public/',
|
||||
PublicUserGroupsView.as_view(),
|
||||
name='public-user-groups'
|
||||
),
|
||||
# схема OpenAPI
|
||||
path('schema/', SpectacularAPIView.as_view(), name='schema'),
|
||||
# Swagger UI, берёт шаблон из drf_spectacular_sidecar
|
||||
path(
|
||||
'swagger/',
|
||||
SpectacularSwaggerView.as_view(url_name='schema'),
|
||||
name='swagger-ui'
|
||||
),
|
||||
|
||||
] + router.urls
|
||||
Reference in New Issue
Block a user