You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/12/02 11:47:06 UTC

[GitHub] [couchdb] bessbd commented on issue #2338: [WIP] Allow all params to be passed via body for POST view

bessbd commented on issue #2338: [WIP] Allow all params to be passed via body for POST view
URL: https://github.com/apache/couchdb/pull/2338#issuecomment-560362182
 
 
   This change would break backwards compatibility for a cleaner API (no query params from now on for POST). Do you think that would be acceptable? If no, can you suggest me a way to have it backwards compatible?
   
   This was my attempt at backwards compatibility (that did not work and does not look very elegant):
   ```
   mrargs_to_list(Rec) ->
           Fields = record_info(fields, mrargs),
           [_Tag| Values] = tuple_to_list(Rec),
           lists:zip(Fields, Values).
   
   list_to_mrargs(Inlist) ->
       Fields = record_info(fields, mrargs),
       [Tag| Values] = tuple_to_list(#mrargs{}),
       Defaults = lists:zip(Fields, Values),
       L = lists:map(fun ({K,V}) -> proplists:get_value(K, Inlist, V) end, Defaults),
       list_to_tuple([Tag|L]).
   
   
   design_doc_post_view(Req, Props, Db, DDoc, ViewName, Keys) ->
       QueryArgs = couch_mrview_http:parse_params(Req, Keys),
       BodyList = couch_mrview_http:parse_body(Props, Keys),
   %%    Args = list_to_mrargs(
   %%        lists:keymerge(1,
   %%            lists:sort(mrargs_to_list(QueryArgs)),
   %%            lists:sort(mrargs_to_list(BodyList))
   %%        )
   %%    ),
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services