(props: { body: string; rawContentType: string })
| 118 | } |
| 119 | |
| 120 | export function BodyInfo(props: { body: string; rawContentType: string }) { |
| 121 | const { body, rawContentType } = props |
| 122 | let formattedBody = null |
| 123 | |
| 124 | if (body) { |
| 125 | if (rawContentType && parseContentType(rawContentType).type === 'application/json') { |
| 126 | formattedBody = <TextBased content={JSON.stringify(JSON.parse(body), null, 2)}></TextBased> |
| 127 | } else { |
| 128 | formattedBody = <TextBased content={body} /> |
| 129 | } |
| 130 | } else { |
| 131 | formattedBody = <Text fontStyle={'italic'}>No content...</Text> |
| 132 | } |
| 133 | |
| 134 | const { onCopy } = useClipboard(body) |
| 135 | return ( |
| 136 | <Box> |
| 137 | <HStack justifyContent={'space-between'} mb="1"> |
| 138 | <Text as="h2" fontWeight={'bold'}> |
| 139 | Body |
| 140 | </Text> |
| 141 | |
| 142 | <IconButton aria-label="Copy body" icon={<CopyIcon />} size="sm" onClick={onCopy}></IconButton> |
| 143 | </HStack> |
| 144 | |
| 145 | {formattedBody} |
| 146 | </Box> |
| 147 | ) |
| 148 | } |
| 149 | |
| 150 | export function getHeader(headers: Record<string, string>, key: string) { |
| 151 | const safeHeaders = Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value])) |
nothing calls this directly
no outgoing calls
no test coverage detected