Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat trait to make clients customizable #459

Merged
merged 109 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
8a4f62d
Feat trait to make clients customizable
shimatar0 Apr 4, 2023
c87aaa8
remove the uneeded Http bound on the tasks and key
irevoire Apr 5, 2023
e0a29fc
Fix incorrect type specification
shimatar0 Apr 5, 2023
8ffe90d
Remove delete unused module
shimatar0 Apr 5, 2023
ec09208
Change the return value of the request function
shimatar0 Apr 5, 2023
d1e421e
Fix return value
shimatar0 Apr 6, 2023
430630e
Add cliant structure correspondence specifying IsahcClient
shimatar0 Apr 6, 2023
2dffdb9
Remove unnecessary specification
shimatar0 Apr 6, 2023
9be62eb
Fix typo, unnecessary comment out
shimatar0 Apr 10, 2023
5c4d3db
Fix macro to generate IndexConfig
shimatar0 Apr 12, 2023
0fc300b
Fix task_info test
shimatar0 Apr 12, 2023
32d3ed0
Fix typo
shimatar0 Apr 12, 2023
1aab7e9
Fix test
shimatar0 Apr 12, 2023
b5b8eb1
Fix settings.rs in example
shimatar0 Apr 12, 2023
a5c4ce9
Change request mod to public
shimatar0 Apr 12, 2023
b12acce
Add stream_request to HttpClient
shimatar0 Apr 12, 2023
e2cd659
Add send and sync trait
shimatar0 Apr 12, 2023
9ca8c74
Change request method calls in setting.rs to use http_client
shimatar0 Apr 12, 2023
b679f69
Change request method calls in client.rs to use http_client
shimatar0 Apr 12, 2023
86e5e91
Change request method calls in indexes.rs to use http_client
shimatar0 Apr 12, 2023
a2384d3
Change request method calls in dumps.rs to use http_client
shimatar0 Apr 12, 2023
a27ec24
Fix async_trait to have Send trait for wasm32 build
shimatar0 Apr 12, 2023
d923605
Fix async trait in index config and macro code
shimatar0 Apr 12, 2023
0f1efbb
Fix clippy warning(never used)
shimatar0 Apr 12, 2023
33f78bc
Fix cli-app example
shimatar0 Apr 12, 2023
9000009
Fix test
shimatar0 Apr 12, 2023
c1477e9
Add example of using reqwest for http_client
shimatar0 Apr 13, 2023
1f722a7
Fix typo
shimatar0 Apr 30, 2023
2f3c3b9
Fix to put underscore on unused variables in example
shimatar0 Apr 30, 2023
e7e2c35
Fix Default to derive
shimatar0 Apr 30, 2023
2a1cc7a
Fix to arrangement client methods
shimatar0 Apr 30, 2023
3bae0d5
Change isahc enables optional flag
shimatar0 May 1, 2023
0b67075
Change functional flags for code that depends on isahc
shimatar0 May 1, 2023
c736c0f
Fix cargo check pass in the no-default-features
shimatar0 May 2, 2023
fb4116a
Fix unused import
shimatar0 May 2, 2023
f7986c7
Fix formatting
shimatar0 May 4, 2023
35221ea
Change disable default-features in the example
shimatar0 May 4, 2023
daa85e8
Fix format
shimatar0 May 4, 2023
6d96c9f
Add client and index types that can be used without specifying an HTT…
shimatar0 May 4, 2023
b5e5da3
Remove unused function
shimatar0 May 16, 2023
71f2abe
Fix to use WebSysClient for wasm
shimatar0 May 16, 2023
bd04a9b
Add prelude
shimatar0 May 16, 2023
5b32627
Fix example to use prelude
shimatar0 May 16, 2023
313ebd2
Fix prelude
shimatar0 May 16, 2023
5993c50
Add to README text about custom HttpClient and link to example.
shimatar0 May 16, 2023
c2e6082
Feat trait to make clients customizable
shimatar0 Apr 4, 2023
70c476e
remove the uneeded Http bound on the tasks and key
irevoire Apr 5, 2023
f420a06
Fix incorrect type specification
shimatar0 Apr 5, 2023
373df8f
Remove delete unused module
shimatar0 Apr 5, 2023
d67d609
Change the return value of the request function
shimatar0 Apr 5, 2023
4ebe4a3
Fix return value
shimatar0 Apr 6, 2023
1793fab
Add cliant structure correspondence specifying IsahcClient
shimatar0 Apr 6, 2023
b7ad11d
Remove unnecessary specification
shimatar0 Apr 6, 2023
84987e4
Fix typo, unnecessary comment out
shimatar0 Apr 10, 2023
53fcf25
Fix macro to generate IndexConfig
shimatar0 Apr 12, 2023
8b7c37c
Fix task_info test
shimatar0 Apr 12, 2023
3f109f1
Fix typo
shimatar0 Apr 12, 2023
7318728
Fix test
shimatar0 Apr 12, 2023
6cdd419
Fix settings.rs in example
shimatar0 Apr 12, 2023
6347f8e
Change request mod to public
shimatar0 Apr 12, 2023
1377764
Add stream_request to HttpClient
shimatar0 Apr 12, 2023
7e85258
Add send and sync trait
shimatar0 Apr 12, 2023
92b00fa
Change request method calls in setting.rs to use http_client
shimatar0 Apr 12, 2023
4ceff03
Change request method calls in client.rs to use http_client
shimatar0 Apr 12, 2023
255ca7c
Change request method calls in indexes.rs to use http_client
shimatar0 Apr 12, 2023
3fb030d
Change request method calls in dumps.rs to use http_client
shimatar0 Apr 12, 2023
464c7d9
Fix async_trait to have Send trait for wasm32 build
shimatar0 Apr 12, 2023
b4d2464
Fix async trait in index config and macro code
shimatar0 Apr 12, 2023
66d4714
Fix clippy warning(never used)
shimatar0 Apr 12, 2023
7edd098
Fix cli-app example
shimatar0 Apr 12, 2023
cdfa844
Fix test
shimatar0 Apr 12, 2023
445c2b3
Add example of using reqwest for http_client
shimatar0 Apr 13, 2023
1844aa4
Fix typo
shimatar0 Apr 30, 2023
0419142
Fix to put underscore on unused variables in example
shimatar0 Apr 30, 2023
3b91e98
Fix Default to derive
shimatar0 Apr 30, 2023
2f19992
Fix to arrangement client methods
shimatar0 Apr 30, 2023
80b70a7
Change isahc enables optional flag
shimatar0 May 1, 2023
a581f5a
Change functional flags for code that depends on isahc
shimatar0 May 1, 2023
95eeca2
Fix cargo check pass in the no-default-features
shimatar0 May 2, 2023
19e4491
Fix unused import
shimatar0 May 2, 2023
b2f7f69
Fix formatting
shimatar0 May 4, 2023
ea9981f
Change disable default-features in the example
shimatar0 May 4, 2023
a765247
Fix format
shimatar0 May 4, 2023
0d436fe
Add client and index types that can be used without specifying an HTT…
shimatar0 May 4, 2023
edf24c2
Remove unused function
shimatar0 May 16, 2023
0779479
Fix to use WebSysClient for wasm
shimatar0 May 16, 2023
6af28c4
Add prelude
shimatar0 May 16, 2023
4543b44
Fix example to use prelude
shimatar0 May 16, 2023
a14e40a
Fix prelude
shimatar0 May 16, 2023
37bd5a3
Add to README text about custom HttpClient and link to example.
shimatar0 May 16, 2023
c0a0bc7
rebase
shimatar0 Jun 18, 2023
c9501bf
Fix rebase commit
shimatar0 Jun 18, 2023
04ea0e0
Add support for new functions
shimatar0 Jun 18, 2023
befd6e7
Merge branch 'main' into customize-http-client
irevoire Apr 8, 2024
53a950c
merge with main
irevoire Apr 8, 2024
97e53f3
make the Client and Index uses our IsahcClient by default
irevoire Apr 9, 2024
5aeb4ef
fix all doctests
irevoire Apr 9, 2024
c5e68b2
fmt
irevoire Apr 9, 2024
db008ca
get rids of the breaking prelude
irevoire Apr 9, 2024
dfeea76
makes clippy happy
irevoire Apr 9, 2024
ab8ddd2
implement serialize myself
irevoire Apr 10, 2024
a198740
make the cargo check --no-default-features works
irevoire Apr 10, 2024
dbadfe7
adds a check in the CI to ensure the no-default-features works forever
irevoire Apr 10, 2024
e1cc66b
Merge branch 'main' into customize-http-client
irevoire Apr 10, 2024
f75eb1c
update the README with the new example
irevoire Apr 10, 2024
25a20db
fix the wasm client
irevoire Apr 10, 2024
78e17c2
adds a TODO
irevoire Apr 10, 2024
692beeb
Update examples/cli-app-with-reqwest/src/main.rs
irevoire Apr 10, 2024
06fe854
Update src/client.rs
irevoire Apr 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
with:
command: check
args: --workspace --all-targets --all
- name: Cargo check no default features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --all --no-default-features

linter:
name: clippy-check
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", ve
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
futures = "0.3"
futures-io = "0.3.26"
isahc = { version = "1.0", features = ["http2", "text-decoding"], default_features = false }
isahc = { version = "1.0", features = ["http2", "text-decoding"], optional = true, default_features = false }
uuid = { version = "1.1.2", features = ["v4"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand All @@ -37,8 +37,8 @@ wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"

[features]
default = ["isahc-static-curl"]
isahc-static-curl = ["isahc/static-curl"]
default = ["isahc", "isahc", "isahc-static-curl"]
isahc-static-curl = ["isahc", "isahc", "isahc/static-curl"]
isahc-static-ssl = ["isahc/static-ssl"]

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ Json output:
}
```

#### Using users customized HttpClient <!-- omit in TOC -->

If you want to change the `HttpClient` you can incorporate using the `Client::new_with_client` method.
To use it, you need to implement the `HttpClient Trait`(`isahc` is used by default).
There are [using-reqwest-example](./examples/cli-app-with-reqwest) of using `reqwest`.

## 🌐 Running in the Browser with WASM <!-- omit in TOC -->

This crate fully supports WASM.
Expand Down
17 changes: 17 additions & 0 deletions examples/cli-app-with-reqwest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "cli-app-with-reqwest"
version = "0.0.0"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
meilisearch-sdk = { path = "../..", default-features = false }
futures = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
lazy_static = "1.4.0"
reqwest = "0.11.16"
async-trait = "0.1.51"
tokio = { version = "1.27.0", features = ["full"] }
74 changes: 74 additions & 0 deletions examples/cli-app-with-reqwest/assets/clothes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"id": 1,
"seaon": "winter",
"article": "sweater",
"cost": 63.40,
"size":"L",
"pattern":"striped"
},
{
"id": 2,
"seaon": "spring",
"article": "sweat pants",
"cost": 18.00,
"size":"XXXL",
"pattern":"floral"
},
{
"id": 3,
"seaon": "fall",
"article": "t-shirt",
"cost": 1634.90,
"size":"M",
"pattern":"solid black"
},
{
"id": 4,
"seaon": "summer",
"article": "tank top",
"cost": 3.40,
"size":"L",
"pattern":"diagonal"
},
{
"id": 5,
"seaon": "winter",
"article": "jeans",
"cost": 4.20,
"size":"XL",
"pattern":"striped"
},
{
"id": 6,
"seaon": "spring",
"article": "sun dress",
"cost": 12634.56,
"size":"L",
"pattern":"floral"
},
{
"id": 7,
"seaon": "fall",
"article": "sweatshirt",
"cost": 90.80,
"size":"M",
"pattern":"checker"
},
{
"id": 8,
"seaon": "summer",
"article": "shorts",
"cost": 16.34,
"size":"XS",
"pattern":"solid beige"
},
{
"id": 9,
"seaon": "winter",
"article": "jacket",
"cost": 634,
"size":"L",
"pattern":"camo"
}
]
Loading
Loading