working database~~
This commit is contained in:
parent
0c5622324c
commit
056c111d88
5 changed files with 99 additions and 92 deletions
|
|
@ -1,17 +1,16 @@
|
|||
(* TODO
|
||||
- pg.ml
|
||||
- preflight
|
||||
- GNU Taler db-events?
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-db-events/registry.rec *)
|
||||
it seems caqti/pgx does not support it *)
|
||||
|
||||
let test req server _ =
|
||||
let pool = Vif.Server.device Devices.caqti server in
|
||||
let (module Conn : Caqti_miou.CONNECTION) =
|
||||
Vif.Server.device Devices.db_connection 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
|
||||
match Conn.find query () with
|
||||
| Ok n ->
|
||||
let open Vif.Response.Syntax in
|
||||
let* () =
|
||||
|
|
@ -26,4 +25,24 @@ let test req server _ =
|
|||
let* () = Vif.Response.with_string req str in
|
||||
Vif.Response.respond `Internal_server_error
|
||||
|
||||
let init = test
|
||||
let test_activate req server _ =
|
||||
(*let (module Conn : Caqti_miou.CONNECTION) =*)
|
||||
let db_conn = Vif.Server.device Devices.db_connection server in
|
||||
let secmod_signkey = Vif.Server.device Devices.secmod_signkey server in
|
||||
let exchange_public_key = secmod_signkey.sm_key in
|
||||
match Pg.activate_signing_key db_conn exchange_public_key with
|
||||
| Ok () ->
|
||||
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 "activate_signing_key done~~@.")
|
||||
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