With this PR, I'm fixing the EndpointRouting Guid regex (route constraint) and adding more automated tests to assert that it's working.
How to test
You can use this project example:
open System
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Giraffe
open Giraffe.EndpointRouting
let endpoints =
[ GET
[ route "/" (text "Hello World")
routef "/try-a-guid/%O" (fun (guid: Guid) -> text $"Success: {guid}") ] ]
let notFoundHandler = "Not Found" |> text |> RequestErrors.notFound
let configureApp (appBuilder: IApplicationBuilder) =
appBuilder.UseRouting().UseGiraffe(endpoints).UseGiraffe(notFoundHandler)
let configureServices (services: IServiceCollection) =
services.AddRouting().AddGiraffe() |> ignore
[<EntryPoint>]
let main args =
let builder = WebApplication.CreateBuilder(args)
configureServices builder.Services
let app = builder.Build()
configureApp app
app.Run()
0
And test with some inputs. For example:
# must not find
curl http://localhost:5000/try-a-guid/8b3557db-fa-c0c90785ec0b
# must work fine
curl http://localhost:5000/try-a-guid/8b3557db-fa-c0c90785ec
# ...
You can find more Guid ideas at the automated tests file.
Description
With this PR, I'm fixing the EndpointRouting Guid regex (route constraint) and adding more automated tests to assert that it's working.
How to test
You can use this project example:
And test with some inputs. For example:
You can find more Guid ideas at the automated tests file.
Related issues