mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-22 23:28:33 -04:00
interpolate reflection url and metadata (#5663)
This commit is contained in:
@@ -106,10 +106,9 @@ const getMethodsFromReflection = async (host: string, metadata: GrpcRequestHeade
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
const loadMethodsFromReflection = async (requestId: string): Promise<GrpcMethodInfo[]> => {
|
||||
const request = await models.grpcRequest.getById(requestId);
|
||||
invariant(request, `Grpc request ${requestId} not found`);
|
||||
const methods = await getMethodsFromReflection(request.url, request.metadata);
|
||||
const loadMethodsFromReflection = async (options: { url: string; metadata: GrpcRequestHeader[] }): Promise<GrpcMethodInfo[]> => {
|
||||
invariant(options.url, 'gRPC request url not provided');
|
||||
const methods = await getMethodsFromReflection(options.url, options.metadata);
|
||||
return methods.map(method => ({
|
||||
type: getMethodType(method),
|
||||
fullPath: method.path,
|
||||
|
||||
@@ -6,7 +6,7 @@ import styled from 'styled-components';
|
||||
import { getCommonHeaderNames, getCommonHeaderValues } from '../../../common/common-headers';
|
||||
import { documentationLinks } from '../../../common/documentation';
|
||||
import { generateId } from '../../../common/misc';
|
||||
import { getRenderedGrpcRequest, getRenderedGrpcRequestMessage, RENDER_PURPOSE_SEND } from '../../../common/render';
|
||||
import { getRenderContext, getRenderedGrpcRequest, getRenderedGrpcRequestMessage, render, RENDER_PURPOSE_SEND } from '../../../common/render';
|
||||
import { GrpcMethodType } from '../../../main/ipc/grpc';
|
||||
import * as models from '../../../models';
|
||||
import type { GrpcRequest, GrpcRequestHeader } from '../../../models/grpc-request';
|
||||
@@ -170,8 +170,13 @@ export const GrpcRequestPane: FunctionComponent<Props> = ({
|
||||
}}
|
||||
handleChangeProtoFile={() => setIsProtoModalOpen(true)}
|
||||
handleServerReflection={async () => {
|
||||
models.grpcRequest.update(activeRequest, { protoMethodName: '', protoFileId: '' });
|
||||
const methods = await window.main.grpc.loadMethodsFromReflection(activeRequest._id);
|
||||
const request = await models.grpcRequest.update(activeRequest, { protoMethodName: '', protoFileId: '' });
|
||||
const renderContext = await getRenderContext({ request, environmentId, purpose: RENDER_PURPOSE_SEND });
|
||||
const rendered = await render({
|
||||
url: request.url,
|
||||
metadata: request.metadata,
|
||||
}, renderContext);
|
||||
const methods = await window.main.grpc.loadMethodsFromReflection(rendered);
|
||||
setGrpcState({ ...grpcState, methods, reloadMethods: false });
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user