Skip to content

[WIP] Let users customize their web client #457

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use futures::Future;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use std::{collections::HashMap, time::Duration};
Expand All @@ -18,6 +19,12 @@ use crate::{
pub struct Client {
pub(crate) host: String,
pub(crate) api_key: String,
request_method: fn(
&str,
&str,
Method<Value, Value>,
u16,
) -> Box<dyn Future<Output = Result<Value, Error>> + Send>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -40,10 +47,11 @@ impl Client {
/// // create the client
/// let client = Client::new(MEILISEARCH_URL, MEILISEARCH_API_KEY);
/// ```
pub fn new(host: impl Into<String>, api_key: impl Into<String>) -> Client {
pub fn new(host: impl Into<String>, api_key: impl Into<String>) -> Self {
Client {
host: host.into(),
api_key: api_key.into(),
request_method: request,
}
}

Expand Down