Logo Orsak

RemoteEndpoints Type

Serves the members of an interface to remote clients, such as the proxies RemoteClient calls.

Static members

Static member Description

RemoteEndpoints.MapRemote(endpoints, prefix, formats, create)

Full Usage: RemoteEndpoints.MapRemote(endpoints, prefix, formats, create)

Parameters:
    endpoints : IEndpointRouteBuilder - The endpoints to add to
    prefix : string - The path the members' routes start with, such as /api
    formats : IWireFormat list - The formats the endpoints read and write, chosen by content type
    create : HttpContext -> 'Api - Makes the implementation that answers a request, such as one running effects in an environment of the request

Returns: RouteGroupBuilder The group of the endpoints, so authorization and other conventions can be added to all of them
Type parameters: 'Api

Maps each member of to a POST endpoint at {prefix}/{interface}/{member}, which reads the member's arguments in the format of the request's content type, calls the member of the implementation create makes for the request, and writes its result in the same format. A content type none of formats has is answered 415, arguments that can't be read 400, and an exception from the implementation is logged and answered 500, without its details.

A member's CancellationToken isn't read from the request: the request's RequestAborted is passed in its place, and an Async is started with it, so a call stops when its client cancels it or goes away, which is logged at the debug level and not answered. The members may return a Task, a ValueTask or an Async, of a value or of none. Reflection finds them, so nothing is generated for the server. The formats' codecs for each member are made here, once, so a type a format can't write fails when the endpoints are mapped, as the application starts, rather than on a call. A member's attributes are its endpoint's metadata, so [<Authorize(Policy = "editors")>] on a member of the interface applies to it alone, while conventions on the returned group apply to all of them.

endpoints : IEndpointRouteBuilder

The endpoints to add to

prefix : string

The path the members' routes start with, such as /api

formats : IWireFormat list

The formats the endpoints read and write, chosen by content type

create : HttpContext -> 'Api

Makes the implementation that answers a request, such as one running effects in an environment of the request

Returns: RouteGroupBuilder

The group of the endpoints, so authorization and other conventions can be added to all of them

Example

 app.MapRemote<IOrderApi>("/api", [ JsonFormat.Instance ], fun ctx -> ServerOrderApi(env ctx))
    .RequireAuthorization()

Type something to start searching.