Skip to content

Commit b304625

Browse files
AugustoRengel64J0
andauthored
docs: fix named parameters docs for endpoint routing (#707)
* docs: fix named parameters docs for endpoint routing * Apply suggestions from code review Co-authored-by: Vinícius Gajo <50725287+64J0@users.noreply.github.com> --------- Co-authored-by: Vinícius Gajo <50725287+64J0@users.noreply.github.com>
1 parent 99d147b commit b304625

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

DOCUMENTATION.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,6 @@ let fooHandler (first : string,
10911091
10921092
let webApp =
10931093
choose [
1094-
// Named parameter example:
1095-
routef "/pet/%i:petId" (fun (petId: int) -> text (sprintf "PetId: %i" petId))
10961094
// Classic usage:
10971095
routef "/foo/%s/%s/%i" fooHandler
10981096
routef "/bar/%O" (fun guid -> text (guid.ToString()))
@@ -1104,7 +1102,7 @@ let webApp =
11041102

11051103
The `routef` http handler takes two parameters - a format string and an `HttpHandler` function.
11061104

1107-
The format string supports the following format chars, and now also supports **named parameters** using the syntax `%c:name` (e.g. `%i:petId`):
1105+
The format string supports the following format chars:
11081106

11091107
| Format Char | Type |
11101108
| ----------- | ---- |
@@ -1117,7 +1115,11 @@ The format string supports the following format chars, and now also supports **n
11171115
| `%O` | `Guid` (including short GUIDs*) |
11181116
| `%u` | `uint64` (formatted as a short ID*) |
11191117

1120-
**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`.
1118+
**Named parameters**: When using ASP.NET Core’s [Endpoint Routing](#endpoint-routing) with Giraffe, you can use `%<type>:<name>` (e.g., `%i:petId`) to assign a name to a route parameter, which is especially useful for OpenAPI/Swagger documentation and for clarity.
1119+
1120+
For example, the route `routef "/pet/%i:petId"` will match `/pet/42` and bind `42` to `petId`.
1121+
1122+
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.
11211123

11221124
*) Please note that the `%O` and `%u` format characters also support URL friendly short GUIDs and IDs.
11231125

0 commit comments

Comments
 (0)