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