package ez_api
Easy API library and tools
Install
Dune Dependency
github.com
Readme
LGPL-2.1-only WITH OCaml-LGPL-linking-exception License
Edit opam file
Versions (6)
Authors
Maintainers
Sources
v1.0.0.tar.gz
md5=d4dcb8a0be9cf87fca6471cecf083d9a
sha512=452a5de00bf0b51926d9c4c5c9062981c372ebce9ccfd0586b1e1b9b42c96721035dc7cd405e4bdd936ae0a7e69f442e4063713756b7cdac246319198fb89e2c
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
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 cannot_destruct (path, exn) = let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String "Cannot destruct JSON"; "path", `String path; "msg", `String exn ] in return ~code:400 ~headers body let unexpected_field f = let body = EzEncoding.construct Json_encoding.any_ezjson_value @@ `O [ "error", `String "Unexpected field in JSON"; "field", `String f ] 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)"
>