mirror of
https://github.com/aantron/dream.git
synced 2025-12-30 00:26:32 -05:00
Make example/4-counter a bit nicer
This commit is contained in:
parent
49772fb9f8
commit
76a8d6c06a
@ -4,7 +4,7 @@
|
||||
|
||||
This example shows how easy it is to define a custom middleware,
|
||||
`count_requests`. It exposes the request count at
|
||||
[http://localhost:8080/dashboard](http://localhost:8080/dashboard):
|
||||
[http://localhost:8080/](http://localhost:8080/) in a sort of dashboard:
|
||||
|
||||
```ocaml
|
||||
let count = ref 0
|
||||
@ -18,7 +18,7 @@ let () =
|
||||
@@ Dream.logger
|
||||
@@ count_requests
|
||||
@@ Dream.router [
|
||||
Dream.get "/dashboard" (fun _ ->
|
||||
Dream.get "/" (fun _ ->
|
||||
Dream.respond (Printf.sprintf "Saw %i request(s)!" !count));
|
||||
]
|
||||
@@ Dream.not_found
|
||||
|
||||
@ -9,7 +9,7 @@ let () =
|
||||
@@ Dream.logger
|
||||
@@ count_requests
|
||||
@@ Dream.router [
|
||||
Dream.get "/dashboard" (fun _ ->
|
||||
Dream.get "/" (fun _ ->
|
||||
Dream.respond (Printf.sprintf "Saw %i request(s)!" !count));
|
||||
]
|
||||
@@ Dream.not_found
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user