MCPcopy Create free account
hub / github.com/SplootCode/splootcode / BodyInfo

Function BodyInfo

packages/editor/src/runtime/response_viewer.tsx:120–148  ·  view source on GitHub ↗
(props: { body: string; rawContentType: string })

Source from the content-addressed store, hash-verified

118}
119
120export 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
150export function getHeader(headers: Record<string, string>, key: string) {
151 const safeHeaders = Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected