diff --git a/README.md b/README.md index b5515c00..1363ef8d 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ import ( func main() { client := meilisearch.NewClient(meilisearch.ClientConfig{ Host: "http://127.0.0.1:7700", - MasterKey: "masterKey", + ApiKey: "masterKey", }) // An index is where the documents are stored. index := client.Index("indexUID") diff --git a/client.go b/client.go index 04c601d2..85ca46ed 100644 --- a/client.go +++ b/client.go @@ -14,8 +14,8 @@ type ClientConfig struct { // Example: 'http://localhost:7700' Host string - // MasterKey is optional - MasterKey string + // ApiKey is optional + ApiKey string // Timeout is optional Timeout time.Duration diff --git a/client_request.go b/client_request.go index fba12ef5..b48312e0 100644 --- a/client_request.go +++ b/client_request.go @@ -104,8 +104,8 @@ func (c *Client) sendRequest(req *internalRequest, internalError *Error, respons // adding request headers request.Header.Set("Content-Type", "application/json") - if c.config.MasterKey != "" { - request.Header.Set("X-Meili-API-Key", c.config.MasterKey) + if c.config.ApiKey != "" { + request.Header.Set("X-Meili-API-Key", c.config.ApiKey) } // request is sent diff --git a/client_test.go b/client_test.go index 2c0cee9f..1cbd7646 100644 --- a/client_test.go +++ b/client_test.go @@ -145,8 +145,8 @@ func TestClient_Health(t *testing.T) { name: "TestHealthWIthBadUrl", client: &Client{ config: ClientConfig{ - Host: "http://wrongurl:1234", - MasterKey: masterKey, + Host: "http://wrongurl:1234", + ApiKey: masterKey, }, httpClient: &fasthttp.Client{ Name: "meilsearch-client", @@ -212,8 +212,8 @@ func TestClient_IsHealthy(t *testing.T) { name: "TestIsHealthyWIthBadUrl", client: &Client{ config: ClientConfig{ - Host: "http://wrongurl:1234", - MasterKey: masterKey, + Host: "http://wrongurl:1234", + ApiKey: masterKey, }, httpClient: &fasthttp.Client{ Name: "meilsearch-client", diff --git a/main_test.go b/main_test.go index 11ebe056..24087202 100644 --- a/main_test.go +++ b/main_test.go @@ -35,8 +35,8 @@ func deleteAllIndexes(client ClientInterface) (ok bool, err error) { func SetUpBasicIndex() { client := NewClient(ClientConfig{ - Host: "http://localhost:7700", - MasterKey: masterKey, + Host: "http://localhost:7700", + ApiKey: masterKey, }) index := client.Index("indexUID") @@ -61,8 +61,8 @@ func SetUpBasicIndex() { func SetUpIndexForFaceting() { client := NewClient(ClientConfig{ - Host: "http://localhost:7700", - MasterKey: masterKey, + Host: "http://localhost:7700", + ApiKey: masterKey, }) index := client.Index("indexUID") @@ -102,13 +102,13 @@ func SetUpIndexForFaceting() { var masterKey = "masterKey" var primaryKey = "primaryKey" var defaultClient = NewClient(ClientConfig{ - Host: "http://localhost:7700", - MasterKey: masterKey, + Host: "http://localhost:7700", + ApiKey: masterKey, }) var customClient = NewFastHTTPCustomClient(ClientConfig{ - Host: "http://localhost:7700", - MasterKey: masterKey, + Host: "http://localhost:7700", + ApiKey: masterKey, }, &fasthttp.Client{ TLSConfig: &tls.Config{InsecureSkipVerify: true}, @@ -116,9 +116,9 @@ var customClient = NewFastHTTPCustomClient(ClientConfig{ }) var timeoutClient = NewClient(ClientConfig{ - Host: "http://localhost:7700", - MasterKey: masterKey, - Timeout: 1, + Host: "http://localhost:7700", + ApiKey: masterKey, + Timeout: 1, }) func TestMain(m *testing.M) {