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

Rename MasterKey by ApiKey #162

Merged
merged 1 commit into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 11 additions & 11 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

Expand Down Expand Up @@ -102,23 +102,23 @@ 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},
Name: "custom-client",
})

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) {
Expand Down