Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-chttpd/pull/56#discussion_r37139946
  
    --- Diff: src/chttpd_db.erl ---
    @@ -362,7 +362,6 @@ 
db_req(#httpd{path_parts=[_,<<"_ensure_full_commit">>]}=Req, _Db) ->
     
     db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>], 
user_ctx=Ctx}=Req, Db) ->
         couch_stats:increment_counter([couchdb, httpd, bulk_requests]),
    -    couch_httpd:validate_ctype(Req, "application/json"),
    --- End diff --
    
    mmm...I think it's conceptually wrong: `chttpd:json_body_obj` ensures that 
request body is a JSON object, but there is more general `json_body` function 
which need to be insured that request body _is_ a JSON value. 
    
    However, both shouldn't care about mime type - that's not their work and 
this prevents to reuse these function if request body is a JSON, but mime type 
is not a `application/json`. For instance, it could be 
`application/vnd.cloudant+json`, but because of `chttpd:json_body` does 
additional wrong job, you'll have to create your own function to decode JSON. 
    
    Single responsibility is a good idea to follow.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to