-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Labels
bugReproducible bugReproducible bug
Description
Describe the bug
Calls to a route with a named parameter, e.g. "/pet/%i:petId" are not matched.
Expected behavior
Calls should be matched as described in the named parameter example in the documentation for routef.
To Reproduce
- Set up a minimal web app:
// GiraffeApp.fsproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Giraffe" Version="7.0.2" />
</ItemGroup>
</Project>// Program.fs
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.DependencyInjection
open Giraffe
let webApp =
choose [
// Named parameter example:
routef "/pet/%i:petId" (fun (petId: int) -> text (sprintf "PetId: %i" petId))
// If none of the routes matched then return a 404
RequestErrors.NOT_FOUND "Not Found"
]
let configureApp (app : IApplicationBuilder) =
// Add Giraffe to the ASP.NET Core pipeline
app.UseGiraffe webApp
let configureServices (services : IServiceCollection) =
// Add Giraffe dependencies
services.AddGiraffe() |> ignore
[<EntryPoint>]
let main _ =
Host.CreateDefaultBuilder()
.ConfigureWebHostDefaults(
fun webHostBuilder ->
webHostBuilder
.Configure(configureApp)
.ConfigureServices(configureServices)
|> ignore)
.Build()
.Run()
0- Start the app and make a call to the endpoint:
PowerShell 7.5.4 PS C:\> curl -X GET "https://localhost:7162/pet/1" -k "Not Found"
Exceptions
None.
Environment:
- OS: Windows 11
- .NET version: 9.0.308
64J0
Metadata
Metadata
Assignees
Labels
bugReproducible bugReproducible bug