Last active
April 30, 2025 16:03
-
-
Save einarwh/15a923869495314c66e5bd4777fb0a29 to your computer and use it in GitHub Desktop.
GET out of the way ASP.NET Core.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Threading.Tasks | |
open Microsoft.AspNetCore.Builder | |
open Microsoft.Extensions.Hosting | |
open Microsoft.AspNetCore.Http | |
let getHandler (ctx : HttpContext) : Task = | |
let routePath = ctx.Request.RouteValues["path"] :?> string | |
let nonNullPath = if routePath = null then "" else routePath | |
ctx.Response.WriteAsync(sprintf "Hello %s" nonNullPath) | |
[<EntryPoint>] | |
let main args = | |
let builder = WebApplication.CreateBuilder(args) | |
let app = builder.Build() | |
app.MapGet("/{**path}", Func<HttpContext, Task>(getHandler)) |> ignore | |
app.Run() | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment