From 1a4890990f1cf0ea71186cf39779690fb533d2df Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Wed, 31 Aug 2022 16:40:30 +0200 Subject: [PATCH 1/3] Fix wasm panic when trying to change the user-agent --- src/request.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/request.rs b/src/request.rs index e3028a6b..939c2635 100644 --- a/src/request.rs +++ b/src/request.rs @@ -109,13 +109,11 @@ pub(crate) async fn request Date: Tue, 6 Sep 2022 17:06:46 +0200 Subject: [PATCH 2/3] Add x-meilisearch-client as header to pass the user agent --- CONTRIBUTING.md | 2 +- src/request.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a0fe3f2..c085c1f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,7 +59,7 @@ Also, the WASM example compilation should be checked: ```bash rustup target add wasm32-unknown-unknown -cargo check --example web_app --target wasm32-unknown-unknown --features=sync +cargo check -p web_app --target wasm32-unknown-unknown ``` Each PR should pass the tests to be accepted. diff --git a/src/request.rs b/src/request.rs index 939c2635..9fcabb28 100644 --- a/src/request.rs +++ b/src/request.rs @@ -114,6 +114,9 @@ pub(crate) async fn request { let query = yaup::to_string(query)?; - mut_url = if query.is_empty() { - mut_url.to_string() - } else { - format!("{}?{}", mut_url, query) + if !query.is_empty() { + mut_url = format!("{}?{}", mut_url, query); }; request.method("GET"); From 19944fa3efafec7bff0423a7e35120bb9b1435a6 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Tue, 6 Sep 2022 17:44:37 +0200 Subject: [PATCH 3/3] Fix wrong authorization header --- examples/web_app/README.md | 4 ++-- examples/web_app/src/lib.rs | 5 +---- src/request.rs | 4 +++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/web_app/README.md b/examples/web_app/README.md index 239bdd8e..ae28fb90 100644 --- a/examples/web_app/README.md +++ b/examples/web_app/README.md @@ -11,7 +11,7 @@ The Rust source files are compiled into WebAssembly and so can be readable by th If you only want to check if this example compiles, you can run: ```console -cargo build --example web_app +cargo build ``` ## Building @@ -23,7 +23,7 @@ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh ``` ```console -wasm-pack build examples/web_app/ --target=web --no-typescript +wasm-pack build . --target=web --no-typescript ``` The compiled files will be stored in the `examples/web_app/pkg` folder. diff --git a/examples/web_app/src/lib.rs b/examples/web_app/src/lib.rs index 921a1f7a..1b965035 100644 --- a/examples/web_app/src/lib.rs +++ b/examples/web_app/src/lib.rs @@ -15,10 +15,7 @@ mod document; use crate::document::{display, Crate}; lazy_static! { - static ref CLIENT: Client = Client::new( - "https://finding-demos.meilisearch.com", - "2b902cce4f868214987a9f3c7af51a69fa660d74a785bed258178b96e3480bb3", - ); + static ref CLIENT: Client = Client::new("http://localhost:7700", "masterKey",); } struct Model { diff --git a/src/request.rs b/src/request.rs index 9fcabb28..5ac7a9b0 100644 --- a/src/request.rs +++ b/src/request.rs @@ -113,7 +113,9 @@ pub(crate) async fn request