package ez_api
Easy API library and tools
Install
Dune Dependency
github.com
Readme
Changelog
LGPL-2.1-only WITH OCaml-LGPL-linking-exception License
Edit opam file
Versions (6)
Authors
Maintainers
Sources
v2.0.0.tar.gz
md5=ed68e0a33325ecf6a3319cafa636d62e
sha512=425c6289d568cf697e8d9977ac43e2ebcdeec8f04f5a17225824d5a37ac700961e5d1283b92aeaebaf58ccfb5b4261bcba1180ab11c267ade0de86b68fd6ca2d
doc/src/ez_api/service.ml.html
Source file service.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
(**************************************************************************) (* *) (* Copyright 2018-2023 OCamlPro *) (* *) (* All rights reserved. This file is distributed under the terms of the *) (* GNU Lesser General Public License version 2.1, with the special *) (* exception on linking described in the file LICENSE. *) (* *) (**************************************************************************) module IO = struct type _ io = | Empty : unit io | Json : 'a Json_encoding.encoding -> 'a io | Raw : Mime.t list -> string io let to_string : type a. a io -> a -> string = fun io a -> match io with | Empty -> "" | Raw _ -> a | Json enc -> EzEncoding.construct enc a let from_string : type a. a io -> (a -> 'b) -> string -> ('b, [> EzEncoding.destruct_error ]) result = fun io f s -> match io with | Empty -> Ok (f ()) | Raw _ -> Ok (f s) | Json enc -> match EzEncoding.destruct_res enc s with | Error e -> Error e | Ok a -> Ok (f a) let res_from_string : type a. a io -> (a Json_encoding.encoding -> (a, 'e) result Json_encoding.encoding) -> ((a, 'e) result -> 'b) -> string -> ('b, [> EzEncoding.destruct_error ]) result = fun io fenc f s -> match io with | Empty -> Ok (f (Ok ())) | Raw _ -> Ok (f (Ok s)) | Json enc -> match EzEncoding.destruct_res (fenc enc) s with | Error e -> Error e | Ok a -> Ok (f a) end type ('args, 'input, 'output, 'error, 'security) t = { path : (Req.t, 'args) Path.t; input : 'input IO.io; output : 'output IO.io; errors : 'error Err.case list; meth : Meth.t; params : Param.t list; security: ([< Security.scheme ] as 'security) list; access_control : (string * string) list } let make = fun ?(meth : Meth.t =`GET) ?(params=[]) ?(security=[]) ?(errors=[]) ?(access_control=[]) ~input ~output path -> { path ; input ; output; errors; meth; params; security; access_control } let input s = s.input let output s = s.output let errors s = s.errors let errors_encoding s = Json_encoding.union @@ List.map (function Err.Case { encoding; select; deselect; _} -> Json_encoding.case encoding select deselect ) (s.errors @ [Err.catch_all_error_case ()]) let meth s = s.meth let path s = s.path let security s = s.security let params s = s.params let access_control s = s.access_control let error s ~code = Err.get ~code s.errors
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>