add caqti device
This commit is contained in:
parent
606d2a6045
commit
4749bb7c62
7 changed files with 83 additions and 6 deletions
25
src/database.ml
Normal file
25
src/database.ml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(* TODO
|
||||
GNU Taler db-events
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-db-events/registry.rec *)
|
||||
|
||||
let test req server _ =
|
||||
let pool = Vif.Server.device Devices.caqti server in
|
||||
let query =
|
||||
let open Caqti_request.Infix in
|
||||
Caqti_type.(unit ->! int) "SELECT 53 - 11"
|
||||
in
|
||||
let fn (module Conn : Caqti_miou.CONNECTION) = Conn.find query () in
|
||||
match Caqti_miou_unix.Pool.use fn pool with
|
||||
| Ok n ->
|
||||
let open Vif.Response.Syntax in
|
||||
let* () =
|
||||
Vif.Response.add ~field:"content-type" "text/plain; charset= utf-8"
|
||||
in
|
||||
let* () = Vif.Response.with_string req (Fmt.str "53 - 11 = %d@." n) in
|
||||
Vif.Response.respond `OK
|
||||
| Error err ->
|
||||
(* TODO don't leak private data in error messages *)
|
||||
let open Vif.Response.Syntax in
|
||||
let str = Fmt.str "Database error: %a." Caqti_error.pp err in
|
||||
let* () = Vif.Response.with_string req str in
|
||||
Vif.Response.respond `Internal_server_error
|
||||
Loading…
Add table
Add a link
Reference in a new issue