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.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=200) ?(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 (Printexc.to_string 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)"
>