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

    https://github.com/apache/couchdb-chttpd/pull/95#discussion_r45228610
  
    --- Diff: src/chttpd.erl ---
    @@ -209,21 +204,58 @@ handle_request_int(MochiReq) ->
                     || Part <- string:tokens(Path, "/")]
         },
     
    -    {ok, HttpReq} = chttpd_plugin:before_request(HttpReq0),
    +    % put small token on heap to keep requests synced to backend calls
    +    erlang:put(nonce, Nonce),
    +
    +    % suppress duplicate log
    +    erlang:put(dont_log_request, true),
    +
    +    Result0 = case before_request(HttpReq0) of
    +        {ok, HttpReq1} ->
    +            process_request(HttpReq1);
    +        {error, Response} ->
    +            {HttpReq0, Response}
    +    end,
    +
    +    {HttpReq3, HttpResp0} = result(Result0, HttpReq0),
    --- End diff --
    
    The way how we form Result0 and how result/2 works very confusing. 
Especially for the case when before_request returns {error, Response}, because 
Response have to be {ok, #httpd{}}  or {aborted, MochiReq, Reason} or you'll 
get function_clause.
    
    Is it possible to make it more friendly for this refactor?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to