2727 OrphansCleanupViewset ,
2828 ReclaimSpaceViewSet ,
2929)
30+ from pulpcore .plugin .find_url import find_api_root
3031
31- if settings .DOMAIN_ENABLED :
32- API_ROOT = settings .V3_DOMAIN_API_ROOT_NO_FRONT_SLASH
33- else :
34- API_ROOT = settings .V3_API_ROOT_NO_FRONT_SLASH
35- if settings .API_ROOT_REWRITE_HEADER :
36- V3_API_ROOT = settings .V3_API_ROOT .replace ("/<path:api_root>/" , settings .API_ROOT )
37- else :
38- V3_API_ROOT = settings .V3_API_ROOT
32+ _ , PATH_DOMAIN_REWRITE_NOFRONT = find_api_root (lstrip = True , set_domain = True , rewrite_header = True )
33+ _ , PATH_NODOMAIN_NOREWRITE_NOFRONT = find_api_root (
34+ lstrip = True , set_domain = False , rewrite_header = False
35+ )
36+ _ , PATH_NODOMAIN_REWRITE_NOFRONT = find_api_root (lstrip = True , set_domain = False , rewrite_header = True )
3937
4038
4139class ViewSetNode :
@@ -199,7 +197,7 @@ class PulpDefaultRouter(routers.DefaultRouter):
199197 SpectacularRedocView .as_view (
200198 authentication_classes = [],
201199 permission_classes = [],
202- url = f"{ V3_API_ROOT } docs/api.json?include_html=1&pk_path=1" ,
200+ url = f"/ { PATH_NODOMAIN_NOREWRITE_NOFRONT } docs/api.json?include_html=1&pk_path=1" ,
203201 )
204202 ),
205203 name = "schema-redoc" ,
@@ -210,17 +208,18 @@ class PulpDefaultRouter(routers.DefaultRouter):
210208 SpectacularSwaggerView .as_view (
211209 authentication_classes = [],
212210 permission_classes = [],
213- url = f"{ V3_API_ROOT } docs/api.json?include_html=1&pk_path=1" ,
211+ url = f"/ { PATH_NODOMAIN_NOREWRITE_NOFRONT } docs/api.json?include_html=1&pk_path=1" ,
214212 )
215213 ),
216214 name = "schema-swagger" ,
217215 ),
218216]
219217
220218urlpatterns = [
221- path (API_ROOT , include (special_views )),
219+ path (PATH_DOMAIN_REWRITE_NOFRONT , include (special_views )),
222220 path ("auth/" , include ("rest_framework.urls" )),
223- path (settings .V3_API_ROOT_NO_FRONT_SLASH , include (docs_and_status )),
221+ # docs/status aren't "inside" a domain
222+ path (PATH_NODOMAIN_REWRITE_NOFRONT , include (docs_and_status )),
224223]
225224
226225if settings .DOMAIN_ENABLED :
@@ -235,7 +234,7 @@ class NoSchema(p.callback.cls):
235234 view = NoSchema .as_view (** p .callback .initkwargs )
236235 name = p .name + "-domains" if p .name else None
237236 docs_and_status_no_schema .append (path (str (p .pattern ), view , name = name ))
238- urlpatterns .insert (- 1 , path (API_ROOT , include (docs_and_status_no_schema )))
237+ urlpatterns .insert (- 1 , path (PATH_DOMAIN_REWRITE_NOFRONT , include (docs_and_status_no_schema )))
239238
240239if "social_django" in settings .INSTALLED_APPS :
241240 urlpatterns .append (
@@ -247,7 +246,7 @@ class NoSchema(p.callback.cls):
247246
248247all_routers = [root_router ] + vs_tree .register_with (root_router )
249248for router in all_routers :
250- urlpatterns .append (path (API_ROOT , include (router .urls )))
249+ urlpatterns .append (path (PATH_DOMAIN_REWRITE_NOFRONT , include (router .urls )))
251250
252251# If plugins define a urls.py, include them into the root namespace.
253252for plugin_pattern in plugin_patterns :
0 commit comments