MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeResponseDecoder

Function makeResponseDecoder

packages/effect/src/http-api/HttpApiClient.ts:1329–1341  ·  view source on GitHub ↗
(alternatives: ReadonlyArray<ResponseAlternative>)

Source from the content-addressed store, hash-verified

1327}
1328
1329function makeResponseDecoder(alternatives: ReadonlyArray<ResponseAlternative>): ResponseDecoder {
1330 const first = alternatives[0]
1331 if (first !== undefined && alternatives.every((alternative) => alternative.decode === first.decode)) {
1332 return first.decode
1333 }
1334 return (response, sseOptions) => {
1335 const contentType = MediaType.normalize(response.headers["content-type"] ?? "")
1336 const alternative = alternatives.find((alternative) => alternative.contentType === contentType)
1337 return alternative === undefined
1338 ? failUnsupportedContentType(response, contentType, alternatives)
1339 : alternative.decode(response, sseOptions)
1340 }
1341}
1342
1343function groupSchemasByContentType(
1344 schemas: Arr.NonEmptyReadonlyArray<Schema.Top>

Callers 2

HttpApiClient.tsFile · 0.85
LanguageModel.tsFile · 0.85

Calls 3

findMethod · 0.65
decodeMethod · 0.45

Tested by

no test coverage detected