aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2020-09-13 16:41:43 +0200
committerAlban Gruin2020-09-13 16:42:20 +0200
commitf60b245498829700f6d321a15bbc079d833758aa (patch)
tree891f2cad58cc101304e510aa1849d8ae2bd8f062
parent2241454988c31521c1f4ff6029399a999396897b (diff)
ucs: show parameters in the log
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
-rw-r--r--src/ucs.ml9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ucs.ml b/src/ucs.ml
index cda7bcc..4a5f490 100644
--- a/src/ucs.ml
+++ b/src/ucs.ml
@@ -30,11 +30,10 @@ let fetch group =
>>= fun (_resp, body) ->
Cohttp_lwt.Body.to_string body
-let log req =
- let uri = Request.uri req and
- datetime = CalendarLib.(
+let log uri =
+ let datetime = CalendarLib.(
Printer.Calendar.sprint "%Y-%m-%d %H:%M:%S" @@ Calendar.now ()) in
- Lwt_io.printlf "[%s] %s" datetime (Uri.path uri)
+ Lwt_io.printlf "[%s] %s" datetime (Uri.path_and_query uri)
let respond ?(mime="text/html; charset=utf-8") ?(status=`OK) body =
let headers = Header.init_with "Content-Type" mime in
@@ -48,7 +47,7 @@ let server =
|> Astring.String.cuts ~empty:false ~sep:"/"
|> List.map Uri.pct_decode and
query = Uri.query uri in
- log req >>= fun () ->
+ log uri >>= fun () ->
match meth, path, query with
| `GET, ([] | ["index.html"]), [] -> respond Pages.main
| `GET, ["lnk"], ["group", [group]] ->