Skip to content

Commit c5590ca

Browse files
committed
Add x-meilisearch-client as header to pass the user agent
1 parent 1a48909 commit c5590ca

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Also, the WASM example compilation should be checked:
5959

6060
```bash
6161
rustup target add wasm32-unknown-unknown
62-
cargo check --example web_app --target wasm32-unknown-unknown --features=sync
62+
cargo check -p web_app --target wasm32-unknown-unknown
6363
```
6464

6565
Each PR should pass the tests to be accepted.

src/request.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ pub(crate) async fn request<Input: Serialize, Output: DeserializeOwned + 'static
114114
let mut mut_url = url.clone().to_string();
115115
let headers = Headers::new().unwrap();
116116
headers.append("Authorization: Bearer", apikey).unwrap();
117+
headers
118+
.append("X-Meilisearch-Client", qualified_version().as_str())
119+
.unwrap();
117120

118121
let mut request: RequestInit = RequestInit::new();
119122
request.headers(&headers);
@@ -122,10 +125,8 @@ pub(crate) async fn request<Input: Serialize, Output: DeserializeOwned + 'static
122125
Method::Get(query) => {
123126
let query = yaup::to_string(query)?;
124127

125-
mut_url = if query.is_empty() {
126-
mut_url.to_string()
127-
} else {
128-
format!("{}?{}", mut_url, query)
128+
if !query.is_empty() {
129+
mut_url = format!("{}?{}", mut_url, query);
129130
};
130131

131132
request.method("GET");

0 commit comments

Comments
 (0)