anchor.diff:          {ok, _} ->
               fslogic_context:set_user_dn(DnString),
               ?info("[REST] Peer connected using certificate with subject: ~p ~n", [DnString]),
  -            do_init(Req2);
  +            {PathInfo, _} = cowboy_req:path_info(Req2),
  +            case rest_routes:route(PathInfo) of
  +                undefined ->
  +                    {ok, Req2, {error, path_invalid}};
  +                {Module, Id} ->
  +                    {Method, _} = cowboy_req:method(Req2),
  +                    {Version, _} = cowboy_req:binding(version, Req2), % :version in cowboy router
  +                    Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
  +                    {ok, Req3, #state{version = Version, handler_module = Module, method = Method, resource_id = Id}}
  +            end;
           _ ->
               {ok, Req2, {error, {user_unknown, DnString}}}
       end.
  
positive.code:     process_callback_answer(Answer, Req2).
  
  
  %% do_init/1
  %% ====================================================================
  %% Initializes request context, without peer validation
  %% @end
  -spec do_init(req()) -> {ok, req(), #state{} | {error, term()}}.
  %% ====================================================================
  do_init(Req) ->
      Req2 = gui_utils:cowboy_ensure_header(<<"content-type">>, <<"application/json">>, Req),
      {PathInfo, _} = cowboy_req:path_info(Req2),
      case rest_routes:route(PathInfo) of
          undefined ->
              {ok, Req2, {error, path_invalid}};
          {Module, Id} ->
              {Method, _} = cowboy_req:method(Req2),
              {Version, _} = cowboy_req:binding(version, Req2), % :version in cowboy router
              Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
              {ok, Req3, #state{version = Version, handler_module = Module, method = Method, resource_id = Id}}
      end.
  %% do_init/2
  %% ====================================================================
  %% Initializes request context after the peer has been validated. Checks if user
  
negative.code: %% @end
  -spec rest_init(req(), term()) -> {ok, req(), term()} | {shutdown, req()}.
  %% ====================================================================
  rest_init(Req, _Opts) ->
      {OtpCert, Certs} = try
          {ok, PeerCert} = ssl:peercert(cowboy_req:get(socket, Req)),
  