Skip to content

Commit da5f5b0

Browse files
committed
Refactor
1 parent d0e7aba commit da5f5b0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/epsilon/server/instances/routes.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ pub async fn get(template: &str, context: &State<Arc<Context>>) -> Result<String
8484
Ok(json!({ "instances": json_array }).to_string())
8585
}
8686

87+
#[rocket::get("/get_from_name/<instance_name>")]
88+
pub async fn get_from_name(
89+
instance_name: &str,
90+
context: &State<Arc<Context>>,
91+
) -> Result<String, EpsilonError> {
92+
let instance_provider = context.get_instance_provider();
93+
let instance = instance_provider.get_instance(instance_name).await?;
94+
95+
Ok(serde_json::to_string(&instance.to_json().await?)
96+
.map_err(|_| EpsilonError::ParseJsonError)?)
97+
}
98+
8799
#[rocket::get("/get_all")]
88100
pub async fn get_all(context: &State<Arc<Context>>) -> Result<String, EpsilonError> {
89101
let instance_provider = context.get_instance_provider();
@@ -103,15 +115,3 @@ pub async fn get_all(context: &State<Arc<Context>>) -> Result<String, EpsilonErr
103115

104116
Ok(json!({ "instances": json_array }).to_string())
105117
}
106-
107-
#[rocket::get("/get_from_name/<instance_name>")]
108-
pub async fn get_from_name(
109-
instance_name: &str,
110-
context: &State<Arc<Context>>,
111-
) -> Result<String, EpsilonError> {
112-
let instance_provider = context.get_instance_provider();
113-
let instance = instance_provider.get_instance(instance_name).await?;
114-
115-
Ok(serde_json::to_string(&instance.to_json().await?)
116-
.map_err(|_| EpsilonError::ParseJsonError)?)
117-
}

0 commit comments

Comments
 (0)