Created
June 21, 2020 17:36
-
-
Save shibafu528/614cc080d0d4d498e61fa8407c7aa321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(JSON.stringify(request)); | |
console.log(JSON.stringify(imports)); | |
console.log(JSON.stringify(server)); | |
const args = []; | |
// -d | |
args.push('-d'); | |
args.push(`'${request.body.replace(/\n/g, '')}'`); | |
// -H | |
for (const key in request.metadata) { | |
args.push('-H'); | |
args.push(`"${key}: ${request.metadata[key]}"`); | |
} | |
// -import-path | |
for (const path of imports) { | |
args.push('-import-path'); | |
args.push(`"${path}"`); | |
} | |
if (imports.length === 0) { | |
const idx = request.protoFile.lastIndexOf('/'); | |
const dir = request.protoFile.substring(0, idx); | |
args.push('-import-path'); | |
args.push(`"${dir}"`); | |
} | |
// -proto | |
args.push('-proto'); | |
args.push(`"${request.protoFile}"`); | |
// server | |
if (server.useTLS) { | |
if (server.certificate.rootCerts) { | |
args.push('-cacert'); | |
args.push(`${server.certificate.rootCerts}`); | |
} | |
if (server.certificate.privateKey) { | |
args.push('-key'); | |
args.push(`${server.certificate.privateKey}`); | |
} | |
if (server.certificate.certChain) { | |
args.push('-cert'); | |
args.push(`${server.certificate.certChain}`); | |
} | |
} else { | |
args.push('-plaintext'); | |
} | |
args.push(server.address); | |
const path = request.path.startsWith('/') ? request.path.substring(1) : request.path; | |
args.push(path); | |
`grpcurl ${args.join(' ')}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment