module Route =
let builder typeName methodName =
sprintf "/api/%s/%s" typeName methodName
type ITodosApi =
{ getTodos: unit -> Async<Todo list>
addTodo: Todo -> Async<Todo> }
let todosApi =
{ getTodos = fun () -> async { return storage.GetTodos() }
addTodo =
fun todo ->
async {
match storage.AddTodo todo with
| Ok () -> return todo
| Error e -> return failwith e
} }
let webApp =
Remoting.createApi ()
|> Remoting.withRouteBuilder Route.builder
|> Remoting.fromValue todosApi
|> Remoting.buildHttpHandler
//http:localhost:8085/api/ITodosApi/getTodos
//http:localhost:8085/api/ITodosApi/addTodo
let todosApi =
Remoting.createApi ()
|> Remoting.withRouteBuilder Route.builder
|> Remoting.buildProxy<ITodosApi>
https://safe-stack.github.io/docs/recipes/client-server/messaging/ https://safe-stack.github.io/docs/recipes/client-server/messaging-post/