diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 94319da1..8694c2c8 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1091,8 +1091,6 @@ let fooHandler (first : string, let webApp = choose [ - // Named parameter example: - routef "/pet/%i:petId" (fun (petId: int) -> text (sprintf "PetId: %i" petId)) // Classic usage: routef "/foo/%s/%s/%i" fooHandler routef "/bar/%O" (fun guid -> text (guid.ToString())) @@ -1104,7 +1102,7 @@ let webApp = The `routef` http handler takes two parameters - a format string and an `HttpHandler` function. -The format string supports the following format chars, and now also supports **named parameters** using the syntax `%c:name` (e.g. `%i:petId`): +The format string supports the following format chars: | Format Char | Type | | ----------- | ---- | @@ -1117,7 +1115,11 @@ The format string supports the following format chars, and now also supports **n | `%O` | `Guid` (including short GUIDs*) | | `%u` | `uint64` (formatted as a short ID*) | -**Named parameters**: You can use `%c:name` to assign a name to a route parameter, which is especially useful for OpenAPI/Swagger documentation and for clarity. For example, `routef "/pet/%i:petId"` will match `/pet/42` and bind `petId` to `42`. +**Named parameters**: When using ASP.NET Core’s [Endpoint Routing](#endpoint-routing) with Giraffe, you can use `%:` (e.g., `%i:petId`) to assign a name to a route parameter, which is especially useful for OpenAPI/Swagger documentation and for clarity. + +For example, the route `routef "/pet/%i:petId"` will match `/pet/42` and bind `42` to `petId`. + +If you'd like to see an example, check the [EndpointRoutingApp sample](https://github.com/giraffe-fsharp/Giraffe/blob/master/samples/EndpointRoutingApp/Program.fs) at the official repository. *) Please note that the `%O` and `%u` format characters also support URL friendly short GUIDs and IDs.