You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm still learning F# and Falco and I'm using a database library that uses Tasks (Dapper.FSharp). I have a working implementation, but wonder if there's a better way than what I've found.
As an example here's my handler:
let getTemplateHandler: HttpHandler =
Services.inject<IDbConnection> (fun dbConn ctx ->
task {
let route = Request.getRoute ctx
let id = route.GetInt64 "id"
let! result = getTemplateService dbConn id
return
match result with
| Some r -> Response.ofJson result ctx
| None -> (Response.withStatusCode 404 >> Response.ofEmpty) ctx
})
I wrapped the whole thing in a task expression in order to call the Task APIs. I also found I'm passing around ctx a lot more compared to the examples.
Am I doing something wrong or is there somewhere I can improve?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm still learning F# and Falco and I'm using a database library that uses Tasks (Dapper.FSharp). I have a working implementation, but wonder if there's a better way than what I've found.
As an example here's my handler:
I wrapped the whole thing in a task expression in order to call the Task APIs. I also found I'm passing around ctx a lot more compared to the examples.
Am I doing something wrong or is there somewhere I can improve?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions