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
1.2.0.tar.gz
md5=55bb40d00db6cd35cbf6ef6cff63363a
sha512=16922b231f19615ca7179a3c7d31e8c3897f2b37f574f69e06b35f12b501434c6eb85bec91cfed16ffd3eec71f8859d94bd003044a848560d434e04a0b1e99e2
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
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)"
>