( schema: Schema.ConstraintCodec<A, unknown, unknown, RE>, options?: ParseOptions | undefined )
| 315 | * @since 4.0.0 |
| 316 | */ |
| 317 | export const schemaJson = <A, RE>( |
| 318 | schema: Schema.ConstraintCodec<A, unknown, unknown, RE>, |
| 319 | options?: ParseOptions | undefined |
| 320 | ) => { |
| 321 | const encode = Body.jsonSchema(schema, options) |
| 322 | return ( |
| 323 | body: A, |
| 324 | options?: Options.WithContentType | undefined |
| 325 | ): Effect.Effect<HttpServerResponse, Body.HttpBodyError, RE> => { |
| 326 | const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty |
| 327 | return Effect.map(encode(body, getContentType(options, headers)), (body) => |
| 328 | makeResponse({ |
| 329 | status: options?.status ?? 200, |
| 330 | statusText: options?.statusText, |
| 331 | headers, |
| 332 | cookies: options?.cookies, |
| 333 | body |
| 334 | })) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Creates a JSON HTTP response synchronously. |
nothing calls this directly
no test coverage detected