From 544333e3a8e8c03c3c01c5579b2f02562defbcd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20L=C3=B6sche?= Date: Thu, 25 Jul 2024 16:17:13 +0200 Subject: [PATCH] Add equivalent curl as debug --- search/search.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/search/search.go b/search/search.go index a9c4031..6a6b9a0 100644 --- a/search/search.go +++ b/search/search.go @@ -8,6 +8,8 @@ import ( "fmt" "io" "net/http" + + "github.com/sirupsen/logrus" ) type SearchRequest struct { @@ -47,6 +49,9 @@ func SearchGraph(apiEndpoint, fixJWT, workspaceID, searchStr string, withEdges b Secure: true, }) + curlCommand := fmt.Sprintf("curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/ndjson' -H 'Cookie: session_token=%s' -d '%s' %s", fixJWT, string(requestBody), url) + logrus.Debugln("Equivalent curl command:", curlCommand) + client := &http.Client{} resp, err := client.Do(req) if err != nil { @@ -76,7 +81,7 @@ func SearchGraph(apiEndpoint, fixJWT, workspaceID, searchStr string, withEdges b var result interface{} if err := decoder.Decode(&result); err != nil { - errs <- fmt.Errorf("error unmarshaling JSON: %w", err) + errs <- fmt.Errorf("error unmarshalling JSON: %w", err) return } results <- result