diff options
Diffstat (limited to 'src/guff/handlers/api.cr')
-rw-r--r-- | src/guff/handlers/api.cr | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/guff/handlers/api.cr b/src/guff/handlers/api.cr index 4401f75..6f5c528 100644 --- a/src/guff/handlers/api.cr +++ b/src/guff/handlers/api.cr @@ -10,8 +10,17 @@ private macro define_method_calls(hash) case method {% for method in methods %} when "{{ method }}" + params = case context.request.method + when "GET" + context.request.query_params + when "POST" + HTTP::Params.parse((context.request.body || "") as String) + else + raise "unsupported method" + end + do_{{ namespace.id }}_{{ method }}(context, get_method_args( - context.request.query_params, + params, "{{ namespace.id }}", "{{ method.id }}" )).to_json |