Browse files

Add get_json convenience function

  • Loading branch information...
1 parent ae70acc commit ff9ea6cfef292f584d2d919fee808fc18af1b58e @VictorNicollet committed May 4, 2012
Showing with 8 additions and 0 deletions.
  1. +5 −0 src/action.ml
  2. +3 −0 src/action.mli
View
5 src/action.ml
@@ -112,6 +112,11 @@ let run callback =
module Convenience = struct
+ let get_json req =
+ match req # post with
+ | Some (`JSON json) -> Some json
+ | _ -> None
+
let nilreq s a = new nilreq s a
let single_domain_server ?(secure=false) ?port ?cookies domain =
View
3 src/action.mli
@@ -372,6 +372,9 @@ val run : (Netcgi_fcgi.cgi -> unit) -> unit
(** Helper functions for your convenience. *)
module Convenience : sig
+ (** Get the JSON data out of a request, or [None] if missing. *)
+ val get_json : ('server,'args) request -> Json_type.t option
+
(** A server that responds to a single domain.
[let server = single_domain_server "www.domain.com"].
*)

0 comments on commit ff9ea6c

Please sign in to comment.