Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active April 30, 2025 16:03
Show Gist options
  • Save einarwh/15a923869495314c66e5bd4777fb0a29 to your computer and use it in GitHub Desktop.
Save einarwh/15a923869495314c66e5bd4777fb0a29 to your computer and use it in GitHub Desktop.
GET out of the way ASP.NET Core.
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