MCPcopy Index your code
hub / github.com/Effect-TS/effect / json

Function json

packages/platform/src/internal/httpServerResponse.ts:196–209  ·  view source on GitHub ↗
(
  body: unknown,
  options?: ServerResponse.Options.WithContentType | undefined
)

Source from the content-addressed store, hash-verified

194
195/** @internal */
196export const json = (
197 body: unknown,
198 options?: ServerResponse.Options.WithContentType | undefined
199): Effect.Effect<ServerResponse.HttpServerResponse, Body.HttpBodyError> => {
200 const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty
201 return Effect.map(internalBody.json(body, getContentType(options, headers)), (body) =>
202 new ServerResponseImpl(
203 options?.status ?? 200,
204 options?.statusText,
205 headers,
206 options?.cookies ?? Cookies.empty,
207 body
208 ))
209}
210
211/** @internal */
212export const unsafeJson = (

Callers

nothing calls this directly

Calls 3

getContentTypeFunction · 0.85
mapMethod · 0.65
jsonMethod · 0.45

Tested by

no test coverage detected