refactor: lint

This commit is contained in:
liyasthomas
2021-05-18 14:57:29 +05:30
parent 7f248da0b3
commit cc27c552af
84 changed files with 1444 additions and 973 deletions

View File

@@ -20,13 +20,20 @@ export const CLibcurlCodegen = {
const requestString = []
requestString.push("CURL *hnd = curl_easy_init();")
requestString.push(`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${method}");`)
requestString.push(`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}${queryString}");`)
requestString.push(
`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${method}");`
)
requestString.push(
`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}${queryString}");`
)
requestString.push(`struct curl_slist *headers = NULL;`)
if (headers) {
headers.forEach(({ key, value }) => {
if (key) requestString.push(`headers = curl_slist_append(headers, "${key}: ${value}");`)
if (key)
requestString.push(
`headers = curl_slist_append(headers, "${key}: ${value}");`
)
})
}
@@ -50,10 +57,15 @@ export const CLibcurlCodegen = {
requestBody = `"${requestBody}"`
} else requestBody = JSON.stringify(requestBody)
requestString.push(`headers = curl_slist_append(headers, "Content-Type: ${contentType}");`)
requestString.push(
`headers = curl_slist_append(headers, "Content-Type: ${contentType}");`
)
requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
requestString.push(
`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${requestBody});`
)
} else
requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
requestString.push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${requestBody});`)
} else requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
requestString.push(`CURLcode ret = curl_easy_perform(hnd);`)
return requestString.join("\n")