( schema: Schema.ConstraintCodec<A, unknown, unknown, RE>, options?: ParseOptions | undefined )
| 336 | * @since 4.0.0 |
| 337 | */ |
| 338 | export const schemaJson = <A, RE>( |
| 339 | schema: Schema.ConstraintCodec<A, unknown, unknown, RE>, |
| 340 | options?: ParseOptions | undefined |
| 341 | ) => { |
| 342 | const encode = Body.jsonSchema(schema, options) |
| 343 | return ( |
| 344 | body: A, |
| 345 | options?: Options.WithContentType | undefined |
| 346 | ): Effect.Effect<HttpServerResponse, Body.HttpBodyError, RE> => { |
| 347 | const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty |
| 348 | return Effect.map(encode(body, getContentType(options, headers)), (body) => |
| 349 | makeResponse({ |
| 350 | status: options?.status ?? 200, |
| 351 | statusText: options?.statusText, |
| 352 | headers, |
| 353 | cookies: options?.cookies, |
| 354 | body |
| 355 | })) |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Creates a JSON HTTP response synchronously. |
nothing calls this directly
no test coverage detected