package ez_api
Easy API library and tools
Install
Dune Dependency
Authors
Maintainers
Sources
2.1.0.tar.gz
md5=e1d03d141ef977fbd4521256c91431f1
sha512=51b0cc4e6afb0cd5ab55c0c40964946b79e0c2cc903b5d08c594292eec723a25e25463175d704c02fe559e2af5d95973514c248a603ad28ec0230c35ad2d6492
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 (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)"
>