Searches route in self.routes and passes found target wsgi_environment,
        response_start and route_result. explanation for route_result is in
        Route class.

        result from ranning this method is simply passed from target to carafe
        calling fuctionality. see Carafe class for explanations to this.

def wsgi_server_target(self, wsgi_environment, response_start):
        """
        Searches route in self.routes and passes found target wsgi_environment,
        response_start and route_result. explanation for route_result is in
        Route class.

        result from ranning this method is simply passed from target to carafe
        calling fuctionality. see Carafe class for explanations to this.
        """

        route_result = {}

        request_method = wsgi_environment['REQUEST_METHOD']

        path_info = wsgi_environment['PATH_INFO']

        if self.PATH_INFO_mode == 'std':
            path_info = path_info.encode('latin1').decode('utf-8')
            wsgi_environment['PATH_INFO'] = path_info

        if path_info.startswith('/'):
            path_info = path_info[1:]

        if path_info in ['/', '']:
            splitted_path_info = []
        else:
            splitted_path_info = path_info.split('/')

        for i in range(len(splitted_path_info)):
            splitted_path_info[i] = self.unquote_callable(
                splitted_path_info[i]
                )

        target = self.default_target

        routing_error = False

        # if len(splitted_path_info) != 0 and len(self.routes) != 0:
        if len(self.routes) != 0:

            path_segment_to_check_position = 0

            filter_result = copy.copy(self.routes)

            # filter by method
            for i in range(len(filter_result) - 1, -1, -1):
                filter_result_i = filter_result[i]
                if ((filter_result_i.method in [None, False])
                        or
                        (filter_result_i.method != True
                         and not request_method in filter_result_i.method)):

                    del filter_result[i]

            # filter by path settings
            for i in range(len(splitted_path_info) - 1, -1, -1):

                if len(filter_result) == 0:
                    break

                filter_result = _filter_routes_by_segment(
                    splitted_path_info[i],
                    filter_result,
                    i
                    )

                if (len(filter_result) == 1
                        and filter_result[0].path_settings[i][0] == 'path'):
                    break

            for i in range(len(filter_result) - 1, -1, -1):
                if (len(filter_result[i].path_settings) >
                        len(splitted_path_info)):
                    del filter_result[i]

            selected_route = None

            filter_result_l = len(filter_result)

            if filter_result_l == 0:
                routing_error = True
                logging.error("route not found")

            elif filter_result_l == 1:
                selected_route = filter_result[0]

            else:
                routing_error = True
                logging.error("can't find matching route")

            #print("selected_route 1: {}".format(selected_route))
            #print("route_result 1: {}".format(route_result))

            if selected_route is not None:

                target = selected_route.target

                for i in range(len(selected_route.path_settings)):

                    selected_route_path_settings_i = \
                        selected_route.path_settings[i]

                    if type(selected_route_path_settings_i[2]) == str:

                        selected_route_path_settings_i_0 = \
                            selected_route_path_settings_i[0]

                        selected_route_path_settings_i_2 = \
                            selected_route_path_settings_i[2]

                        if selected_route_path_settings_i_0 == 'path':
                            route_result[selected_route_path_settings_i_2] = \
                                splitted_path_info[i:]
                            break

                        elif selected_route_path_settings_i_0 == '=':
                            route_result[selected_route_path_settings_i_2] = \
                                (selected_route.path_settings[i]
                                 == splitted_path_info[i])

                        elif selected_route_path_settings_i_0 == 'rer':
                            route_result[selected_route_path_settings_i_2] = \
                                selected_route.path_settings[i].match(
                                    splitted_path_info[i]
                                    )

                        elif selected_route_path_settings_i_0 in ['fm', 're']:
                            route_result[selected_route_path_settings_i_2] = \
                                splitted_path_info[i]

                        else:
                            raise Exception("programming error")

            #print("route_result 2: {}".format(route_result))

        if routing_error:
            logging.error(
                "routing error\n"
                "   asked route is: {}\n"
                "   starting  route list is: {}\n"
                "   resulting route list is: {}".format(
                    path_info,
                    self.routes,
                    filter_result
                    )
                )

        if len(self.routes) == 0:
            logging.warning("routes not specified")

        return target(wsgi_environment, response_start, route_result)