Skip to content

Commit

Permalink
Add get_json convenience function
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorNicollet committed May 4, 2012
1 parent ae70acc commit ff9ea6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 3 additions & 0 deletions src/action.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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"].
*)
Expand Down

0 comments on commit ff9ea6c

Please sign in to comment.