You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Nightly builds and NuGet feed](#nightly-builds-and-nuget-feed)
18
+
-[More information](#more-information)
19
+
-[License](#license)
20
+
21
+
## Documentation
22
+
23
+
The `Giraffe.TokenRouter` module adds alternative `HttpHandler` functions to route incoming HTTP requests through a basic [Radix Tree](https://en.wikipedia.org/wiki/Radix_tree). Several routing handlers (e.g.: `routef` and `subRoute`) have been overridden in such a way that path matching and value parsing are significantly faster than using the basic `choose` function.
24
+
25
+
This implementation assumes that additional memory and compilation time is not an issue. If speed and performance of parsing and path matching is required then the `Giraffe.TokenRouter` is the preferred option.
26
+
27
+
### router
28
+
29
+
The base of all routing decisions is a `router` function instead of the default `choose` function when using the `Giraffe.TokenRouter` module.
30
+
31
+
The `router` HttpHandler takes two arguments, a `HttpHandler` to execute when no route can be matched (typical 404 Not Found handler) and secondly a list of all routing functions.
32
+
33
+
#### Example:
34
+
35
+
Defining a basic router and routes
36
+
37
+
```fsharp
38
+
let notFound = setStatusCode 404 >=> text "Not found"
39
+
let app =
40
+
router notFound [
41
+
route "/" (text "index")
42
+
route "/about" (text "about")
43
+
]
44
+
```
45
+
46
+
### routing functions
47
+
48
+
When using the `Giraffe.TokenRouter` module the main routing functions have been slightly overridden to match the alternative (speed improved) implementation.
49
+
50
+
The `route` and `routef` handlers work the exact same way as before, except that the continuation handler needs to be enclosed in parentheses or captured by the `<|` or `=>` operators.
51
+
52
+
The http handlers `GET`, `POST`, `PUT` and `DELETE` are functions which take a list of nested http handler functions similar to before.
53
+
54
+
The `subRoute` handler has been altered in order to accept an additional parameter of child routing functions. All child routing functions will presume that the given sub path has been prepended.
55
+
56
+
#### Example:
57
+
58
+
Defining a basic router and routes
59
+
60
+
```fsharp
61
+
let notFound = setStatusCode 404 >=> text "Not found"
62
+
let app =
63
+
router notFound [
64
+
route "/" (text "index")
65
+
route "/about" (text "about")
66
+
routef "parsing/%s/%i" (fun (s,i) -> text (sprintf "Recieved %s & %i" s i))
67
+
subRoute "/api" [
68
+
GET [
69
+
route "/" (text "api index")
70
+
route "/about" (text "api about")
71
+
subRoute "/v2" [
72
+
route "/" (text "api v2 index")
73
+
route "/about" (text "api v2 about")
74
+
]
75
+
]
76
+
77
+
]
78
+
]
79
+
```
80
+
81
+
## Nightly builds and NuGet feed
82
+
83
+
All official Giraffe packages are published to the official and public NuGet feed.
84
+
85
+
Unofficial builds (such as pre-release builds from the `develop` branch and pull requests) produce unofficial pre-release NuGet packages which can be pulled from the project's public NuGet feed on AppVeyor:
86
+
87
+
```
88
+
https://ci.appveyor.com/nuget/giraffe-tokenrouter
89
+
```
90
+
91
+
If you add this source to your NuGet CLI or project settings then you can pull unofficial NuGet packages for quick feature testing or urgent hot fixes.
92
+
93
+
## More information
94
+
95
+
For more information about Giraffe, how to set up a development environment, contribution guidelines and more please visit the [main documentation](https://github.com/giraffe-fsharp/Giraffe/blob/master/DOCUMENTATION.md) page.
- Moved `Giraffe.TokenRouter` into its own repository with its own release cycle and NuGet package deployment.
7
+
8
+
## 0.1.0-beta-100 and before
9
+
10
+
Previous releases of this library were documented in [Giraffe's release notes](https://github.com/giraffe-fsharp/Giraffe/blob/master/RELEASE_NOTES.md).
0 commit comments