Skip to content

Commit

Permalink
Add value binding extension for services
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtori committed Oct 13, 2023
1 parent b6de7ad commit 483abc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/ppx/ppx_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ let rec impl ?kind str =
deprecate a.attr_name.txt;
let service, _, _ = service_value ~client:true ~meth:a.attr_name.txt ~loc:a.attr_loc a.attr_payload in
service :: acc
| Pstr_extension (({txt; loc}, PStr [ { pstr_desc = Pstr_value (_, [ { pvb_expr; pvb_pat= {ppat_desc=Ppat_var {txt=name; _}; _}; _} ]); _} ]), _) when List.mem txt methods ->
let service, _, _ = service_value ~name ~client:true ~meth:txt ~loc @@ PStr [ pstr_eval ~loc pvb_expr [] ] in
service :: acc
| Pstr_extension (({txt; loc}, p), _) when List.mem txt methods ->
let service, _, _ = service_value ~client:true ~meth:txt ~loc p in
service :: acc
Expand Down
6 changes: 4 additions & 2 deletions test/ppx/test_ppx_lib.ml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[%%post {path="/echo_input"; name="echo_input"; raw_input=["text/plain"];
output=Json_encoding.(obj1 (req "test" string))}]
let%post echo_input = {
path="/echo_input"; raw_input=["text/plain"];
output=Json_encoding.(obj1 (req "test" string))
}

0 comments on commit 483abc2

Please sign in to comment.