From 1ad23f4ed87498046e270aa9746b9b8e8d5b7fe5 Mon Sep 17 00:00:00 2001 From: Saswata Mukherjee Date: Sat, 3 Oct 2020 12:36:55 +0530 Subject: [PATCH] Fix: GET requests for Go codegen (#1216) --- helpers/codegen/generators/go-native.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helpers/codegen/generators/go-native.js b/helpers/codegen/generators/go-native.js index 692b9893f..1b484ad17 100644 --- a/helpers/codegen/generators/go-native.js +++ b/helpers/codegen/generators/go-native.js @@ -22,7 +22,13 @@ export const GoNativeCodegen = { let genHeaders = [] // initial request setup let requestBody = rawInput ? rawParams : rawRequestBody + if (method == "GET") { + requestString.push( + `req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}")\n` + ) + } if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) { + genHeaders.push(`req.Header.Set("Content-Type", "${contentType}")\n`) if (isJSONContentType(contentType)) { requestString.push(`var reqBody = []byte(\`${requestBody}\`)\n\n`) requestString.push( @@ -36,7 +42,6 @@ export const GoNativeCodegen = { } // headers - genHeaders.push(`req.Header.Set("Content-Type", "${contentType}")\n`) // auth if (auth === "Basic Auth") { const basic = `${httpUser}:${httpPassword}`