mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 03:11:12 +01:00
Add other body type
This commit is contained in:
@@ -16,7 +16,7 @@ use std::process::exit;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use ::http::uri::InvalidUri;
|
use ::http::uri::InvalidUri;
|
||||||
use ::http::{HeaderValue, Uri};
|
use ::http::Uri;
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use fern::colors::ColoredLevelConfig;
|
use fern::colors::ColoredLevelConfig;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useUpdateHttpRequest } from '../hooks/useUpdateHttpRequest';
|
|||||||
import { tryFormatJson } from '../lib/formatters';
|
import { tryFormatJson } from '../lib/formatters';
|
||||||
import type { HttpHeader, HttpRequest, HttpUrlParameter } from '../lib/models';
|
import type { HttpHeader, HttpRequest, HttpUrlParameter } from '../lib/models';
|
||||||
import {
|
import {
|
||||||
|
BODY_TYPE_OTHER,
|
||||||
AUTH_TYPE_BASIC,
|
AUTH_TYPE_BASIC,
|
||||||
AUTH_TYPE_BEARER,
|
AUTH_TYPE_BEARER,
|
||||||
AUTH_TYPE_NONE,
|
AUTH_TYPE_NONE,
|
||||||
@@ -68,6 +69,7 @@ export const RequestPane = memo(function RequestPane({
|
|||||||
{ label: 'JSON', value: BODY_TYPE_JSON },
|
{ label: 'JSON', value: BODY_TYPE_JSON },
|
||||||
{ label: 'XML', value: BODY_TYPE_XML },
|
{ label: 'XML', value: BODY_TYPE_XML },
|
||||||
{ label: 'GraphQL', value: BODY_TYPE_GRAPHQL },
|
{ label: 'GraphQL', value: BODY_TYPE_GRAPHQL },
|
||||||
|
{ label: 'Other', value: BODY_TYPE_OTHER },
|
||||||
{ type: 'separator', label: 'Other' },
|
{ type: 'separator', label: 'Other' },
|
||||||
{ label: 'No Body', shortLabel: 'Body', value: BODY_TYPE_NONE },
|
{ 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_URLENCODED ||
|
||||||
bodyType === BODY_TYPE_FORM_MULTIPART ||
|
bodyType === BODY_TYPE_FORM_MULTIPART ||
|
||||||
bodyType === BODY_TYPE_JSON ||
|
bodyType === BODY_TYPE_JSON ||
|
||||||
|
bodyType === BODY_TYPE_OTHER ||
|
||||||
bodyType === BODY_TYPE_XML
|
bodyType === BODY_TYPE_XML
|
||||||
) {
|
) {
|
||||||
patch.method = 'POST';
|
patch.method = 'POST';
|
||||||
@@ -275,6 +278,17 @@ export const RequestPane = memo(function RequestPane({
|
|||||||
contentType="text/xml"
|
contentType="text/xml"
|
||||||
onChange={handleBodyTextChange}
|
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 ? (
|
) : activeRequest.bodyType === BODY_TYPE_GRAPHQL ? (
|
||||||
<GraphQLEditor
|
<GraphQLEditor
|
||||||
forceUpdateKey={forceUpdateKey}
|
forceUpdateKey={forceUpdateKey}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export const BODY_TYPE_NONE = null;
|
export const BODY_TYPE_NONE = null;
|
||||||
export const BODY_TYPE_GRAPHQL = 'graphql';
|
export const BODY_TYPE_GRAPHQL = 'graphql';
|
||||||
export const BODY_TYPE_JSON = 'application/json';
|
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_URLENCODED = 'application/x-www-form-urlencoded';
|
||||||
export const BODY_TYPE_FORM_MULTIPART = 'multipart/form-data';
|
export const BODY_TYPE_FORM_MULTIPART = 'multipart/form-data';
|
||||||
export const BODY_TYPE_XML = 'text/xml';
|
export const BODY_TYPE_XML = 'text/xml';
|
||||||
|
|||||||
Reference in New Issue
Block a user