Skip to content

Commit

Permalink
serve console index at /settings/*
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Jun 30, 2022
1 parent 4b133fa commit d3b9e36
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions nexus/src/external_api/console_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,22 +558,8 @@ pub async fn session_me(
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
}

// Dropshot does not have route match ranking and does not allow overlapping
// route definitions, so we cannot have a catchall `/*` route for console pages
// and then also define, e.g., `/api/blah/blah` and give the latter priority
// because it's a more specific match. So for now we simply give the console
// catchall route a prefix to avoid overlap. Long-term, if a route prefix is
// part of the solution, we would probably prefer it to be on the API endpoints,
// not on the console pages. Conveniently, all the console page routes start
// with /orgs already.
#[endpoint {
method = GET,
path = "/orgs/{path:.*}",
unpublished = true,
}]
pub async fn console_page(
async fn console_page_inner(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_path_params: Path<RestPathParam>,
) -> Result<Response<Body>, HttpError> {
let opctx = OpContext::for_external_api(&rqctx).await;

Expand All @@ -599,6 +585,38 @@ pub async fn console_page(
.body("".into())?)
}

// Dropshot does not have route match ranking and does not allow overlapping
// route definitions, so we cannot have a catchall `/*` route for console pages
// and then also define, e.g., `/api/blah/blah` and give the latter priority
// because it's a more specific match. So for now we simply give the console
// catchall route a prefix to avoid overlap. Long-term, if a route prefix is
// part of the solution, we would probably prefer it to be on the API endpoints,
// not on the console pages. Conveniently, all the console page routes start
// with /orgs already.
#[endpoint {
method = GET,
path = "/orgs/{path:.*}",
unpublished = true,
}]
pub async fn console_page(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_path_params: Path<RestPathParam>,
) -> Result<Response<Body>, HttpError> {
console_page_inner(rqctx).await
}

#[endpoint {
method = GET,
path = "/settings/{path:.*}",
unpublished = true,
}]
pub async fn console_settings_page(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_path_params: Path<RestPathParam>,
) -> Result<Response<Body>, HttpError> {
console_page_inner(rqctx).await
}

/// Fetch a static asset from `<static_dir>/assets`. 404 on virtually all
/// errors. No auth. NO SENSITIVE FILES.
#[endpoint {
Expand Down

0 comments on commit d3b9e36

Please sign in to comment.