mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
feat: Streamline gRPC requests to use right context
This commit is contained in:
@@ -42,10 +42,17 @@ const getCertsAndProxyConfig = async ({
|
||||
httpsAgentRequestFields['ca'] = caCertificates || [];
|
||||
|
||||
const { promptVariables } = collection;
|
||||
const collectionVariables = request.collectionVariables || {};
|
||||
const folderVariables = request.folderVariables || {};
|
||||
const requestVariables = request.requestVariables || {};
|
||||
|
||||
const brunoConfig = getBrunoConfig(collectionUid, collection);
|
||||
const interpolationOptions = {
|
||||
globalEnvironmentVariables,
|
||||
collectionVariables,
|
||||
envVars,
|
||||
folderVariables,
|
||||
requestVariables,
|
||||
runtimeVariables,
|
||||
promptVariables,
|
||||
processEnvVars
|
||||
|
||||
@@ -35,15 +35,18 @@ const registerGrpcEventHandlers = (window) => {
|
||||
|
||||
try {
|
||||
const requestCopy = cloneDeep(request);
|
||||
|
||||
|
||||
const preparedRequest = await prepareGrpcRequest(requestCopy, collection, environment, runtimeVariables, {});
|
||||
|
||||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;
|
||||
if (!protocolRegex.test(preparedRequest.url)) {
|
||||
preparedRequest.url = `http://${preparedRequest.url}`;
|
||||
}
|
||||
|
||||
// Get certificates and proxy configuration
|
||||
const certsAndProxyConfig = await getCertsAndProxyConfig({
|
||||
collectionUid: collection.uid,
|
||||
collection,
|
||||
request: requestCopy.request,
|
||||
request: preparedRequest,
|
||||
envVars: preparedRequest.envVars,
|
||||
runtimeVariables,
|
||||
processEnvVars: preparedRequest.processEnvVars,
|
||||
@@ -171,12 +174,17 @@ const registerGrpcEventHandlers = (window) => {
|
||||
try {
|
||||
const requestCopy = cloneDeep(request);
|
||||
const preparedRequest = await prepareGrpcRequest(requestCopy, collection, environment, runtimeVariables);
|
||||
|
||||
|
||||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;
|
||||
if (!protocolRegex.test(preparedRequest.url)) {
|
||||
preparedRequest.url = `http://${preparedRequest.url}`;
|
||||
}
|
||||
|
||||
// Get certificates and proxy configuration
|
||||
const certsAndProxyConfig = await getCertsAndProxyConfig({
|
||||
collectionUid: collection.uid,
|
||||
collection,
|
||||
request: requestCopy.request,
|
||||
request: preparedRequest,
|
||||
envVars: preparedRequest.envVars,
|
||||
runtimeVariables,
|
||||
processEnvVars: preparedRequest.processEnvVars,
|
||||
@@ -279,6 +287,12 @@ const registerGrpcEventHandlers = (window) => {
|
||||
try {
|
||||
const requestCopy = cloneDeep(request);
|
||||
const preparedRequest = await prepareGrpcRequest(requestCopy, collection, environment, runtimeVariables, {});
|
||||
|
||||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;
|
||||
if (!protocolRegex.test(preparedRequest.url)) {
|
||||
preparedRequest.url = `http://${preparedRequest.url}`;
|
||||
}
|
||||
|
||||
const interpolationOptions = {
|
||||
envVars: preparedRequest.envVars,
|
||||
runtimeVariables,
|
||||
|
||||
@@ -112,7 +112,8 @@ const configureRequest = async (
|
||||
globalEnvironmentVariables
|
||||
) => {
|
||||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;
|
||||
if (!protocolRegex.test(request.url)) {
|
||||
const hasVariables = request.url.startsWith('{{');
|
||||
if (!hasVariables && !protocolRegex.test(request.url)) {
|
||||
request.url = `http://${request.url}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
const { forOwn, cloneDeep } = require('lodash');
|
||||
const { interpolate } = require('@usebruno/common');
|
||||
|
||||
const interpolateString = (str, { globalEnvironmentVariables, envVars, runtimeVariables, processEnvVars, promptVariables }) => {
|
||||
const interpolateString = (str, {
|
||||
globalEnvironmentVariables,
|
||||
collectionVariables,
|
||||
envVars,
|
||||
folderVariables,
|
||||
requestVariables,
|
||||
runtimeVariables,
|
||||
processEnvVars,
|
||||
promptVariables
|
||||
}) => {
|
||||
if (!str || !str.length || typeof str !== 'string') {
|
||||
return str;
|
||||
}
|
||||
@@ -9,6 +18,9 @@ const interpolateString = (str, { globalEnvironmentVariables, envVars, runtimeVa
|
||||
processEnvVars = processEnvVars || {};
|
||||
runtimeVariables = runtimeVariables || {};
|
||||
globalEnvironmentVariables = globalEnvironmentVariables || {};
|
||||
collectionVariables = collectionVariables || {};
|
||||
folderVariables = folderVariables || {};
|
||||
requestVariables = requestVariables || {};
|
||||
promptVariables = promptVariables || {};
|
||||
|
||||
// we clone envVars because we don't want to modify the original object
|
||||
@@ -29,7 +41,10 @@ const interpolateString = (str, { globalEnvironmentVariables, envVars, runtimeVa
|
||||
// runtimeVariables take precedence over envVars
|
||||
const combinedVars = {
|
||||
...globalEnvironmentVariables,
|
||||
...collectionVariables,
|
||||
...envVars,
|
||||
...folderVariables,
|
||||
...requestVariables,
|
||||
...runtimeVariables,
|
||||
...promptVariables,
|
||||
process: {
|
||||
|
||||
Reference in New Issue
Block a user