mirror of
https://github.com/aantron/dream.git
synced 2025-12-31 00:03:52 -05:00
Echo handler for debugging
This commit is contained in:
parent
a30edb3a81
commit
0074b391bc
6
example/w-echo/Makefile
Normal file
6
example/w-echo/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
.PHONY : run
|
||||
run :
|
||||
@tput rmam || true
|
||||
@stty -echo || true
|
||||
@dune exec --no-print-directory -- ./echo.exe
|
||||
@tput smam || true
|
||||
1
example/w-echo/README.md
Normal file
1
example/w-echo/README.md
Normal file
@ -0,0 +1 @@
|
||||
<!-- TODO -->
|
||||
3
example/w-echo/dune
Normal file
3
example/w-echo/dune
Normal file
@ -0,0 +1,3 @@
|
||||
(executable
|
||||
(name echo)
|
||||
(libraries dream))
|
||||
1
example/w-echo/dune-project
Normal file
1
example/w-echo/dune-project
Normal file
@ -0,0 +1 @@
|
||||
(lang dune 2.0)
|
||||
2
example/w-echo/echo.ml
Normal file
2
example/w-echo/echo.ml
Normal file
@ -0,0 +1,2 @@
|
||||
let () =
|
||||
Dream.run (Dream.logger Dream.echo)
|
||||
7
example/w-echo/echo.opam
Normal file
7
example/w-echo/echo.opam
Normal file
@ -0,0 +1,7 @@
|
||||
opam-version: "2.0"
|
||||
|
||||
depends: [
|
||||
"dream"
|
||||
"dune" {>= "2.0.0"}
|
||||
"ocaml"
|
||||
]
|
||||
@ -14,6 +14,7 @@ end
|
||||
include Dream__pure.Inmost
|
||||
|
||||
include Dream__middleware.Log
|
||||
include Dream__middleware.Echo
|
||||
|
||||
let logger =
|
||||
Dream__middleware.Log.logger
|
||||
|
||||
@ -747,6 +747,8 @@ val logger : middleware
|
||||
next handler has returned a response. Time spent logging is included in the
|
||||
timings. *)
|
||||
|
||||
val echo : handler
|
||||
|
||||
|
||||
|
||||
(** {1 Routing} *)
|
||||
|
||||
14
src/middleware/echo.ml
Normal file
14
src/middleware/echo.ml
Normal file
@ -0,0 +1,14 @@
|
||||
(* This file is part of Dream, released under the MIT license. See
|
||||
LICENSE.md for details, or visit https://github.com/aantron/dream.
|
||||
|
||||
Copyright 2021 Anton Bachin *)
|
||||
|
||||
|
||||
|
||||
module Dream = Dream__pure.Inmost
|
||||
|
||||
|
||||
|
||||
(* TODO Convert to streaming later. *)
|
||||
let echo request =
|
||||
Lwt.map Dream.response (Dream.body request)
|
||||
Loading…
x
Reference in New Issue
Block a user