summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lambda-calcul/rust/src/web.rs30
1 files changed, 21 insertions, 9 deletions
diff --git a/lambda-calcul/rust/src/web.rs b/lambda-calcul/rust/src/web.rs
index 2c2789b..ac618b1 100644
--- a/lambda-calcul/rust/src/web.rs
+++ b/lambda-calcul/rust/src/web.rs
@@ -19,6 +19,13 @@ use lambda::parser::{parse, parse_total};
struct Registration {
url: String,
name: String,
+ encoding: Option<AstEncoding>,
+}
+
+#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+enum AstEncoding {
+ Json,
+ Sexp,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -342,7 +349,7 @@ async fn main() -> std::io::Result<()> {
.service(register)
.service(eval)
.service(leaderboard)
- .service(actix_files::Files::new("/", "./static").show_files_listing() )
+ .service(actix_files::Files::new("/", "./static").show_files_listing())
})
.bind((options.host, options.port))?
.run()
@@ -413,6 +420,14 @@ mod app_tests {
use super::*;
+ fn default_registration(url: String) -> Registration {
+ Registration {
+ url: url.clone(),
+ name: "foo".to_string(),
+ encoding: None,
+ }
+ }
+
#[actix_web::test]
async fn post_registration_returns_success_with_unique_id() {
let state = Arc::new(Mutex::new(State::new()));
@@ -429,10 +444,7 @@ mod app_tests {
let url = "http://192.168.1.1".to_string();
let req = test::TestRequest::post()
.uri("/register")
- .set_json(Registration {
- url: url.clone(),
- name: "foo".to_string(),
- })
+ .set_json(default_registration(url.clone()))
.insert_header(ContentType::json())
.to_request();
@@ -460,10 +472,7 @@ mod app_tests {
)
.await;
let url = "http://192.168.1.1".to_string();
- let registration = Registration {
- url: url.clone(),
- name: "foo".to_string(),
- };
+ let registration = default_registration(url.clone());
state.lock().unwrap().register(&registration);
@@ -526,6 +535,7 @@ mod app_tests {
app_state.lock().unwrap().register(&Registration {
url: "http://1.2.3.4".to_string(),
name: "client1".to_string(),
+ encoding: None,
});
let mut handlebars = Handlebars::new();
@@ -565,6 +575,7 @@ mod app_tests {
let registration = Registration {
name: "foo".to_string(),
url: "http://1.2.3.4".to_string(),
+ encoding: None,
};
app_state.register(&registration);
@@ -584,6 +595,7 @@ mod app_tests {
let registration = Registration {
name: "foo".to_string(),
url: "http://1.2.3.4".to_string(),
+ encoding: None,
};
let reg = app_state.register(&registration);