A couple of potential improvements: 1. You can use match! instead of let! and match: match! featureManager.IsEnabledAsync("customGreeting") with | true -> return! ctx.WriteTextAsync "Hello Jonathan, how are you?" | false -> return! ctx.WriteTextAsync"Hello, how are you?"
2. I like to split the routes out to make them more readable: let featuresRoutes : HttpHandler = subRoute "/features" (choose [ GET >=> choose [ route "" >=> getFeatureResponse ] ])
let webApp: HttpHandler = choose [ route "/" >=> text "Welcome to my API" featuresRoutes ] Nice post!
A couple of potential improvements:
1. You can use match! instead of let! and match:
match! featureManager.IsEnabledAsync("customGreeting") with
| true -> return! ctx.WriteTextAsync "Hello Jonathan, how are you?"
| false -> return! ctx.WriteTextAsync"Hello, how are you?"
2. I like to split the routes out to make them more readable:
let featuresRoutes : HttpHandler =
subRoute "/features"
(choose [
GET >=> choose [
route "" >=> getFeatureResponse
]
])
let webApp: HttpHandler =
choose [
route "/" >=> text "Welcome to my API"
featuresRoutes
]
Nice post!