anchor.diff:  %%%-------------------------------------------------------------------
   %%% @author evangelosp
  -%%% @copyright (C) 2014, <COMPANY>
  +%%% @copyright (C) 2014, evalonlabs
   %%% @doc
   %%%
   %%% @end
  
positive.code: known_methods(Req, State) ->
    {[<<"GET">>, <<"HEAD">>, <<"POST">>, <<"PUT">>, <<"PATCH">>, <<"DELETE">>, <<"OPTIONS">>], Req, State}.
  
  %% FLOW: ALL[3] OR 414
  %% Return whether the requested URI is too long.
  uri_too_long(Req, State) -> {false, Req, State}.
  
  %% FLOW: ALL[4] OR 405
  %% Return the list of allowed methods.
  allowed_methods(Req, State) ->
    Method = cowboy_req:method(Req),
    NewState = State#state{method = Method},
    {[<<"POST">>, <<"PUT">>, <<"OPTIONS">>], Req, NewState}.
  
  %% FLOW: ALL[5] OR 400
  %% Return whether the request is malformed.
  malformed_request(Req, State) ->
    #{email := EmailBin, password := PasswordBin} = cowboy_req:match_qs([
      {email, [], undefined},
      {password, [], undefined}
    ], Req),
  
    case EmailBin =/= undefined andalso
      PasswordBin =/= undefined of
  
negative.code:       Email = binary_to_list(EmailBin),
        Password = binary_to_list(PasswordBin),
  
        case user_server:register(Email, Password) of
          {ok, Registred} ->
            NewState = State#state{registred = Registred},
            {true, cowboy_req:set_resp_body(jiffy:encode({Registred}), Req), NewState};
          _ -> {false, Req, State}
        end;
      false ->
        {stop, Req, State}
    end.
  