UNPKG

@curveball/browser

Version:

Automatic API browser generator. A middleware that turns your JSON responses into HTML if accessed by a browser.

26 lines 924 B
import * as React from 'react'; import { MarkdownBody } from './markdown-body.js'; import { CsvBody } from './csv-body.js'; import { HalBody } from './hal-body.js'; export function Body(props) { if (!props.resourceState.data) { // Ignore empty bodies return null; } const contentType = props.resourceState.contentHeaders().get('Content-Type'); switch (contentType) { case 'application/json': case 'application/problem+json': case 'application/hal+json': case 'application/schema+json': case 'application/vnd.siren+json': return React.createElement(HalBody, { ...props }); case 'text/markdown': return React.createElement(MarkdownBody, { ...props }); case 'text/csv': return React.createElement(CsvBody, { ...props }); default: return null; } } //# sourceMappingURL=body.js.map