package ez_api
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Easy API library and tools
Install
dune-project
Dependency
Authors
Maintainers
Sources
2.2.0.tar.gz
md5=08f55e6d79d09fd4b14e48981ea89963
sha512=3b00866b03aab19c6f6eac79bd94dfd24bf66829303c03491523476bc9302962f7ff4a820e0b2215ce6362c09ec3da8f65d57908b8f85598154e0f677323843d
doc/src/ez_api.server_utils/answer.ml.html
Source file answer.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(**************************************************************************) (* *) (* 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. *) (* *) (**************************************************************************) type 'a t = { code : int; body : 'a; headers : (string * string) list; } let return ?(code= -1) ?(headers=[]) body = Lwt.return {code; body; headers} let not_found () = return ~code:404 "" let headers = [ "content-type", "application/json" ] let cannot_parse (descr, msg, path) = let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String ("Cannot parse path argument " ^ descr.EzAPI.Arg.name); "path", `String (String.concat "/" path); "msg", `String msg ] in return ~code:400 ~headers body let method_not_allowed () = return ~code:405 "" let destruct_exception exn = let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String "Destruct exception"; "exception", `String (Format.asprintf "%a" (Json_encoding.print_error ?print_unknown:None) exn) ] in return ~code:400 ~headers body let unsupported_media_type c = let c = match c with None -> "none" | Some c -> c in let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String "Unsupported Media Type"; "content_type", `String c ] in return ~code:415 ~headers body let server_error exn = let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String "Server Error"; "msg", `String (Printexc.to_string exn) ] in return ~code:500 ~headers body
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>