Skip to content

Commit f1c8583

Browse files
authored
expose uninteruptible option to HttpApiBuilder .handle apis (#4803)
1 parent ee14444 commit f1c8583

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

.changeset/moody-ducks-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/platform": patch
3+
---
4+
5+
expose uninteruptible option to HttpApiBuilder .handle apis

packages/platform/src/HttpApiBuilder.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ export interface Handlers<
219219
*/
220220
handle<Name extends HttpApiEndpoint.HttpApiEndpoint.Name<Endpoints>, R1>(
221221
name: Name,
222-
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerWithName<Endpoints, Name, E, R1>
222+
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerWithName<Endpoints, Name, E, R1>,
223+
options?: { readonly uninterruptible?: boolean | undefined } | undefined
223224
): Handlers<
224225
E,
225226
Provides,
@@ -241,7 +242,8 @@ export interface Handlers<
241242
*/
242243
handleRaw<Name extends HttpApiEndpoint.HttpApiEndpoint.Name<Endpoints>, R1>(
243244
name: Name,
244-
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerResponseWithName<Endpoints, Name, E, R1>
245+
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerResponseWithName<Endpoints, Name, E, R1>,
246+
options?: { readonly uninterruptible?: boolean | undefined } | undefined
245247
): Handlers<
246248
E,
247249
Provides,
@@ -285,6 +287,7 @@ export declare namespace Handlers {
285287
readonly endpoint: HttpApiEndpoint.HttpApiEndpoint.Any
286288
readonly handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, E, R>
287289
readonly withFullResponse: boolean
290+
readonly uninterruptible: boolean
288291
}
289292

290293
/**
@@ -378,30 +381,34 @@ const HandlersProto = {
378381
handle(
379382
this: Handlers<any, any, any, HttpApiEndpoint.HttpApiEndpoint.Any>,
380383
name: string,
381-
handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, any, any>
384+
handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, any, any>,
385+
options?: { readonly uninterruptible?: boolean | undefined } | undefined
382386
) {
383387
const endpoint = this.group.endpoints[name]
384388
return makeHandlers({
385389
group: this.group,
386390
handlers: Chunk.append(this.handlers, {
387391
endpoint,
388392
handler,
389-
withFullResponse: false
393+
withFullResponse: false,
394+
uninterruptible: options?.uninterruptible ?? false
390395
}) as any
391396
})
392397
},
393398
handleRaw(
394399
this: Handlers<any, any, any, HttpApiEndpoint.HttpApiEndpoint.Any>,
395400
name: string,
396-
handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, any, any>
401+
handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, any, any>,
402+
options?: { readonly uninterruptible?: boolean | undefined } | undefined
397403
) {
398404
const endpoint = this.group.endpoints[name]
399405
return makeHandlers({
400406
group: this.group,
401407
handlers: Chunk.append(this.handlers, {
402408
endpoint,
403409
handler,
404-
withFullResponse: true
410+
withFullResponse: true,
411+
uninterruptible: options?.uninterruptible ?? false
405412
}) as any
406413
})
407414
}
@@ -473,7 +480,8 @@ export const group = <
473480
(input) => Context.merge(context, input)
474481
)
475482
},
476-
item.withFullResponse
483+
item.withFullResponse,
484+
item.uninterruptible
477485
))
478486
}
479487
yield* router.concat(HttpRouter.fromIterable(routes))
@@ -615,7 +623,8 @@ const handlerToRoute = (
615623
endpoint_: HttpApiEndpoint.HttpApiEndpoint.Any,
616624
middleware: MiddlewareMap,
617625
handler: HttpApiEndpoint.HttpApiEndpoint.Handler<any, any, any>,
618-
isFullResponse: boolean
626+
isFullResponse: boolean,
627+
uninterruptible: boolean
619628
): HttpRouter.Route<any, any> => {
620629
const endpoint = endpoint_ as HttpApiEndpoint.HttpApiEndpoint.AnyWithProps
621630
const decodePath = Option.map(endpoint.pathSchema, Schema.decodeUnknown)
@@ -657,7 +666,8 @@ const handlerToRoute = (
657666
}).pipe(
658667
Effect.catchIf(ParseResult.isParseError, HttpApiDecodeError.refailParseError)
659668
)
660-
)
669+
),
670+
{ uninterruptible }
661671
)
662672
}
663673

0 commit comments

Comments
 (0)