chore: publish metadata wrapper
This commit is contained in:
parent
9a4d633dd3
commit
9ee04b8958
|
|
@ -292,7 +292,7 @@ impl Client {
|
||||||
publish_name: &str,
|
publish_name: &str,
|
||||||
) -> Result<T, AppResponseError>
|
) -> Result<T, AppResponseError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned,
|
T: serde::de::DeserializeOwned + 'static,
|
||||||
{
|
{
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"get_published_collab: {} {}",
|
"get_published_collab: {} {}",
|
||||||
|
|
@ -300,7 +300,7 @@ impl Client {
|
||||||
publish_name
|
publish_name
|
||||||
);
|
);
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/api/workspace/published/{}/{}",
|
"{}/v1/api/workspace/published/{}/{}",
|
||||||
self.base_url, publish_namespace, publish_name
|
self.base_url, publish_namespace, publish_name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -312,15 +312,7 @@ impl Client {
|
||||||
.error_for_status()?;
|
.error_for_status()?;
|
||||||
log_request_id(&resp);
|
log_request_id(&resp);
|
||||||
|
|
||||||
let txt = resp.text().await?;
|
AppResponse::<T>::from_response(resp).await?.into_data()
|
||||||
|
|
||||||
if let Ok(app_err) = serde_json::from_str::<AppResponseError>(&txt) {
|
|
||||||
return Err(app_err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let meta = serde_json::from_str::<T>(&txt)?;
|
|
||||||
|
|
||||||
Ok(meta)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip_all)]
|
#[instrument(level = "debug", skip_all)]
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,13 @@ pub fn workspace_scope() -> Scope {
|
||||||
.route(web::get().to(get_default_published_collab_info_meta_handler)),
|
.route(web::get().to(get_default_published_collab_info_meta_handler)),
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/published/{publish_namespace}/{publish_name}")
|
web::resource("/published/{publish_namespace}/{publish_name}") // Deprecated
|
||||||
.route(web::get().to(get_published_collab_handler)),
|
.route(web::get().to(get_published_collab_handler)),
|
||||||
)
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/v1/published/{publish_namespace}/{publish_name}")
|
||||||
|
.route(web::get().to(get_v1_published_collab_handler)),
|
||||||
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/published/{publish_namespace}/{publish_name}/blob")
|
web::resource("/published/{publish_namespace}/{publish_name}/blob")
|
||||||
.route(web::get().to(get_published_collab_blob_handler)),
|
.route(web::get().to(get_published_collab_blob_handler)),
|
||||||
|
|
@ -1218,6 +1222,7 @@ async fn get_default_published_collab_info_meta_handler(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated
|
||||||
async fn get_published_collab_handler(
|
async fn get_published_collab_handler(
|
||||||
path_param: web::Path<(String, String)>,
|
path_param: web::Path<(String, String)>,
|
||||||
state: Data<AppState>,
|
state: Data<AppState>,
|
||||||
|
|
@ -1230,6 +1235,18 @@ async fn get_published_collab_handler(
|
||||||
Ok(Json(metadata))
|
Ok(Json(metadata))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_v1_published_collab_handler(
|
||||||
|
path_param: web::Path<(String, String)>,
|
||||||
|
state: Data<AppState>,
|
||||||
|
) -> Result<Json<AppResponse<serde_json::Value>>> {
|
||||||
|
let (workspace_namespace, publish_name) = path_param.into_inner();
|
||||||
|
let metadata = state
|
||||||
|
.published_collab_store
|
||||||
|
.get_collab_metadata(&workspace_namespace, &publish_name)
|
||||||
|
.await?;
|
||||||
|
Ok(Json(AppResponse::Ok().with_data(metadata)))
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_published_collab_blob_handler(
|
async fn get_published_collab_blob_handler(
|
||||||
path_param: web::Path<(String, String)>,
|
path_param: web::Path<(String, String)>,
|
||||||
state: Data<AppState>,
|
state: Data<AppState>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue