Add other body type

This commit is contained in:
Gregory Schier
2024-02-18 08:59:14 -08:00
parent 7f4d082c17
commit ec5cdfb025
3 changed files with 16 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ use std::process::exit;
use std::str::FromStr;
use ::http::uri::InvalidUri;
use ::http::{HeaderValue, Uri};
use ::http::Uri;
use base64::Engine;
use fern::colors::ColoredLevelConfig;
use log::{debug, error, info, warn};

View File

@@ -9,6 +9,7 @@ import { useUpdateHttpRequest } from '../hooks/useUpdateHttpRequest';
import { tryFormatJson } from '../lib/formatters';
import type { HttpHeader, HttpRequest, HttpUrlParameter } from '../lib/models';
import {
BODY_TYPE_OTHER,
AUTH_TYPE_BASIC,
AUTH_TYPE_BEARER,
AUTH_TYPE_NONE,
@@ -68,6 +69,7 @@ export const RequestPane = memo(function RequestPane({
{ label: 'JSON', value: BODY_TYPE_JSON },
{ label: 'XML', value: BODY_TYPE_XML },
{ label: 'GraphQL', value: BODY_TYPE_GRAPHQL },
{ label: 'Other', value: BODY_TYPE_OTHER },
{ type: 'separator', label: 'Other' },
{ label: 'No Body', shortLabel: 'Body', value: BODY_TYPE_NONE },
],
@@ -81,6 +83,7 @@ export const RequestPane = memo(function RequestPane({
bodyType === BODY_TYPE_FORM_URLENCODED ||
bodyType === BODY_TYPE_FORM_MULTIPART ||
bodyType === BODY_TYPE_JSON ||
bodyType === BODY_TYPE_OTHER ||
bodyType === BODY_TYPE_XML
) {
patch.method = 'POST';
@@ -275,6 +278,17 @@ export const RequestPane = memo(function RequestPane({
contentType="text/xml"
onChange={handleBodyTextChange}
/>
) : activeRequest.bodyType === BODY_TYPE_OTHER ? (
<Editor
forceUpdateKey={forceUpdateKey}
useTemplating
autocompleteVariables
placeholder="..."
className="!bg-gray-50"
heightMode={fullHeight ? 'full' : 'auto'}
defaultValue={`${activeRequest.body?.text ?? ''}`}
onChange={handleBodyTextChange}
/>
) : activeRequest.bodyType === BODY_TYPE_GRAPHQL ? (
<GraphQLEditor
forceUpdateKey={forceUpdateKey}

View File

@@ -1,6 +1,7 @@
export const BODY_TYPE_NONE = null;
export const BODY_TYPE_GRAPHQL = 'graphql';
export const BODY_TYPE_JSON = 'application/json';
export const BODY_TYPE_OTHER = 'other';
export const BODY_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded';
export const BODY_TYPE_FORM_MULTIPART = 'multipart/form-data';
export const BODY_TYPE_XML = 'text/xml';