couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: [15/15] git commit: refactor is_preflight_request() for clarity
Date Fri, 09 Nov 2012 08:09:36 GMT
I find it quite a bit more readable.


On Fri, Nov 9, 2012 at 12:23 AM, Benoit Chesneau <bchesneau@gmail.com>wrote:

> Hrm I don't find it more clear... Now you have to look at 2 places to
> know what this true or false is about. the case was enough. Also why
> not reusing the enable_cors() new fonction ?
>
> On Thu, Nov 8, 2012 at 11:44 PM,  <jan@apache.org> wrote:
> > refactor is_preflight_request() for clarity
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f976cfef
> > Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f976cfef
> > Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f976cfef
> >
> > Branch: refs/heads/431-feature_cors
> > Commit: f976cfef52450a3c6c6ffd5049f5805037f874da
> > Parents: eccc28b
> > Author: Jan Lehnardt <jan@apache.org>
> > Authored: Thu Nov 8 22:19:27 2012 +0100
> > Committer: Jan Lehnardt <jan@apache.org>
> > Committed: Thu Nov 8 23:37:33 2012 +0100
> >
> > ----------------------------------------------------------------------
> >  src/couchdb/couch_httpd_cors.erl |   22 +++++++++++-----------
> >  1 files changed, 11 insertions(+), 11 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f976cfef/src/couchdb/couch_httpd_cors.erl
> > ----------------------------------------------------------------------
> > diff --git a/src/couchdb/couch_httpd_cors.erl
> b/src/couchdb/couch_httpd_cors.erl
> > index 6f501cc..a783ae6 100644
> > --- a/src/couchdb/couch_httpd_cors.erl
> > +++ b/src/couchdb/couch_httpd_cors.erl
> > @@ -32,20 +32,20 @@
> >
> >  is_preflight_request(#httpd{method=Method}=Req) when Method /=
> 'OPTIONS' ->
> >      Req;
> > -is_preflight_request(#httpd{mochi_req=MochiReq}=Req) ->
> > -    case get_bool_config("httpd", "enable_cors", false) of
> > -        true ->
> > -            case preflight_request(MochiReq) of
> > -                {ok, PreflightHeaders} ->
> > -                    send_preflight_response(Req, PreflightHeaders);
> > -                _ ->
> > -                    Req
> > -            end;
> > -        false ->
> > +is_preflight_request(Req) ->
> > +    EnableCors = get_bool_config("httpd", "enable_cors", false),
> > +    is_preflight_request(Req, EnableCors).
> > +
> > +is_preflight_request(Req, false) ->
> > +    Req;
> > +is_preflight_request(#httpd{mochi_req=MochiReq}=Req, true) ->
> > +    case preflight_request(MochiReq) of
> > +        {ok, PreflightHeaders} ->
> > +            send_preflight_response(Req, PreflightHeaders);
> > +        _ ->
> >              Req
> >      end.
> >
> > -
> >  cors_headers(#httpd{mochi_req=MochiReq}) ->
> >      Host = couch_httpd_vhost:host(MochiReq),
> >      case get_bool_config("httpd", "enable_cors", false) of
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message