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

Function schemaJson

packages/platform/src/internal/httpServerResponse.ts:227–246  ·  view source on GitHub ↗
(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

225
226/** @internal */
227export const schemaJson = <A, I, R>(
228 schema: Schema.Schema<A, I, R>,
229 options?: ParseOptions | undefined
230) => {
231 const encode = internalBody.jsonSchema(schema, options)
232 return (
233 body: A,
234 options?: ServerResponse.Options.WithContentType | undefined
235 ): Effect.Effect<ServerResponse.HttpServerResponse, Body.HttpBodyError, R> => {
236 const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty
237 return Effect.map(encode(body, getContentType(options, headers)), (body) =>
238 new ServerResponseImpl(
239 options?.status ?? 200,
240 options?.statusText,
241 headers,
242 options?.cookies ?? Cookies.empty,
243 body
244 ))
245 }
246}
247
248const httpPlatform = Context.GenericTag<Platform.HttpPlatform>("@effect/platform/HttpPlatform")
249

Callers

nothing calls this directly

Calls 3

getContentTypeFunction · 0.85
encodeFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected