2626 OrphansCleanupViewset ,
2727 ReclaimSpaceViewSet ,
2828)
29+ from pulpcore .plugin .find_url import find_api_root
2930
30- if settings .DOMAIN_ENABLED :
31- API_ROOT = settings .V3_DOMAIN_API_ROOT_NO_FRONT_SLASH
32- else :
33- API_ROOT = settings .V3_API_ROOT_NO_FRONT_SLASH
34- if settings .API_ROOT_REWRITE_HEADER :
35- V3_API_ROOT = settings .V3_API_ROOT .replace ("/<path:api_root>/" , settings .API_ROOT )
36- else :
37- V3_API_ROOT = settings .V3_API_ROOT
31+ _ , PATH_DOMAIN_REWRITE_NOFRONT = find_api_root (lstrip = True , set_domain = True , rewrite_header = True )
32+ _ , PATH_NODOMAIN_NOREWRITE_NOFRONT = find_api_root (
33+ lstrip = True , set_domain = False , rewrite_header = False
34+ )
35+ _ , PATH_NODOMAIN_REWRITE_NOFRONT = find_api_root (lstrip = True , set_domain = False , rewrite_header = True )
3836
3937
4038class ViewSetNode :
@@ -191,7 +189,7 @@ class PulpDefaultRouter(routers.DefaultRouter):
191189 SpectacularRedocView .as_view (
192190 authentication_classes = [],
193191 permission_classes = [],
194- url = f"{ V3_API_ROOT } docs/api.json?include_html=1&pk_path=1" ,
192+ url = f"/ { PATH_NODOMAIN_NOREWRITE_NOFRONT } docs/api.json?include_html=1&pk_path=1" ,
195193 ),
196194 name = "schema-redoc" ,
197195 ),
@@ -200,16 +198,17 @@ class PulpDefaultRouter(routers.DefaultRouter):
200198 SpectacularSwaggerView .as_view (
201199 authentication_classes = [],
202200 permission_classes = [],
203- url = f"{ V3_API_ROOT } docs/api.json?include_html=1&pk_path=1" ,
201+ url = f"/ { PATH_NODOMAIN_NOREWRITE_NOFRONT } docs/api.json?include_html=1&pk_path=1" ,
204202 ),
205203 name = "schema-swagger" ,
206204 ),
207205]
208206
209207urlpatterns = [
210- path (API_ROOT , include (special_views )),
208+ path (PATH_DOMAIN_REWRITE_NOFRONT , include (special_views )),
211209 path ("auth/" , include ("rest_framework.urls" )),
212- path (settings .V3_API_ROOT_NO_FRONT_SLASH , include (docs_and_status )),
210+ # docs/status aren't "inside" a domain
211+ path (PATH_NODOMAIN_REWRITE_NOFRONT , include (docs_and_status )),
213212]
214213
215214if settings .DOMAIN_ENABLED :
@@ -224,7 +223,7 @@ class NoSchema(p.callback.cls):
224223 view = NoSchema .as_view (** p .callback .initkwargs )
225224 name = p .name + "-domains" if p .name else None
226225 docs_and_status_no_schema .append (path (str (p .pattern ), view , name = name ))
227- urlpatterns .insert (- 1 , path (API_ROOT , include (docs_and_status_no_schema )))
226+ urlpatterns .insert (- 1 , path (PATH_DOMAIN_REWRITE_NOFRONT , include (docs_and_status_no_schema )))
228227
229228if "social_django" in settings .INSTALLED_APPS :
230229 urlpatterns .append (
@@ -236,7 +235,7 @@ class NoSchema(p.callback.cls):
236235
237236all_routers = [root_router ] + vs_tree .register_with (root_router )
238237for router in all_routers :
239- urlpatterns .append (path (API_ROOT , include (router .urls )))
238+ urlpatterns .append (path (PATH_DOMAIN_REWRITE_NOFRONT , include (router .urls )))
240239
241240# If plugins define a urls.py, include them into the root namespace.
242241for plugin_pattern in plugin_patterns :
0 commit comments