Files
hoppscotch/helpers/lenses/lenses.js
Kévin Dunglas 07f370d6d2 feat: better media types detection for JSON, XML and HTML lenses (#1438)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
2021-01-26 09:57:11 +05:30

29 lines
719 B
JavaScript

import jsonLens from "./jsonLens"
import rawLens from "./rawLens"
import imageLens from "./imageLens"
import htmlLens from "./htmlLens"
import xmlLens from "./xmlLens"
export const lenses = [jsonLens, imageLens, htmlLens, xmlLens, rawLens]
export function getSuitableLenses(response) {
if (!response || !response.headers || !response.headers["content-type"])
return [rawLens]
const result = []
for (const lens of lenses) {
if (lens.isSupportedContentType(response.headers["content-type"]))
result.push(lens)
}
return result
}
export function getLensRenderers() {
const response = {}
for (const lens of lenses) {
response[lens.renderer] = lens.rendererImport
}
return response
}