add not_implemented handler

This commit is contained in:
swrup 2026-03-30 10:03:08 +02:00 committed by Swrup
parent f3483594ac
commit 18c4f0b3d5
4 changed files with 38 additions and 3 deletions

View file

@ -11,6 +11,7 @@
mte_terms
mte_info
mte_management
mte_handler
secmod_eddsa
secmod_rsa
keys

View file

@ -97,8 +97,9 @@ let () =
Caqti_miou.Switch.run @@ fun sw ->
(* -- *)
let fs = Fat.create storage in
let env = Global.{ sw; stack; tcp; dns; fs } in
let devices = Vifu.Devices.[ Global.db_conn; Global.keys ] in
let cfg = Vifu.Config.v Config.Exchange.port in
let devices = Vifu.Devices.[ Global.db_conn; Global.keys ] in
let handlers = [ Mte_handler.not_implemented_route ] in
let env = Global.{ sw; stack; tcp; dns; fs } in
Logs.info (fun m -> m "Starting MTE server");
Vifu.run ~cfg ~devices tcp routes env
Vifu.run ~cfg ~devices ~handlers tcp routes env

28
src/mte_handler.ml Normal file
View file

@ -0,0 +1,28 @@
let not_implemented_route : (string, Global.env) Vifu.Handler.t =
let uri_prefix_list =
[
"auditors";
"reserves";
"coins";
"transfers";
"deposits";
"purses";
"contracts";
"wads";
"kyc";
"aml";
"reserves-attest";
]
in
let uri_prefix_list =
uri_prefix_list
|> List.map (fun prefix ->
let open Vifu.Uri in
rel / prefix /% option rest /?? any)
in
fun req _v _server (_env : Global.env) ->
let target = Vifu.Request.target req in
Logs.debug (fun m -> m "not_implemented_route_handler `%s`" target);
uri_prefix_list
|> List.find_opt (fun uri -> Vifu.Uri.execp uri target)
|> Option.map (fun _uri -> Respond.not_implemented req)

View file

@ -56,6 +56,11 @@ let error req err =
Logs.err (fun m -> m "%s: %s" (status_to_string status) hint);
respond_json req Api.ErrorDetail.jsont status body
let not_implemented req =
Logs.debug (fun m -> m "Not implemented");
let body = error_detail "Not Implemented" in
respond_json req Api.ErrorDetail.jsont `Not_implemented body
let result req jsont res =
match res with Error e -> error req e | Ok body -> ok req jsont body