Fix: GET requests for Go codegen (#1216)
This commit is contained in:
committed by
GitHub
parent
1bcba17f76
commit
1ad23f4ed8
@@ -22,7 +22,13 @@ export const GoNativeCodegen = {
|
|||||||
let genHeaders = []
|
let genHeaders = []
|
||||||
// initial request setup
|
// initial request setup
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
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)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
|
genHeaders.push(`req.Header.Set("Content-Type", "${contentType}")\n`)
|
||||||
if (isJSONContentType(contentType)) {
|
if (isJSONContentType(contentType)) {
|
||||||
requestString.push(`var reqBody = []byte(\`${requestBody}\`)\n\n`)
|
requestString.push(`var reqBody = []byte(\`${requestBody}\`)\n\n`)
|
||||||
requestString.push(
|
requestString.push(
|
||||||
@@ -36,7 +42,6 @@ export const GoNativeCodegen = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// headers
|
// headers
|
||||||
genHeaders.push(`req.Header.Set("Content-Type", "${contentType}")\n`)
|
|
||||||
// auth
|
// auth
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
|
|||||||
Reference in New Issue
Block a user