Static helper to create and dispatch a request.
503097
public static function run(array $stack, ServerRequestInterface $request = null): ResponseInterface
    {
        if ($request === null) {
            $request = Factory::createServerRequest('GET', '/');
        }

        return (new static($stack))->dispatch($request);
    }
921830
def dispatch_operation(self, operation, request, path_args):
        # type: (Operation, BaseHttpRequest, Dict[str, Any]) -> Tuple[Any, Optional[HTTPStatus], Optional[dict]]
        
        try:
            # path_args is passed by ref so changes can be made.
            for middleware in self.middleware.pre_dispatch:
                middleware(request, path_args)

            resource = operation(request, path_args)

            for middleware in self.middleware.post_dispatch:
                resource = middleware(request, resource)

        except ImmediateHttpResponse as e:
            # An exception used to return a response immediately, skipping any
            # further processing.
            return e.resource, e.status, e.headers

        except ValidationError as e:
            # A validation error was raised by a resource.
            if hasattr(e, 'message_dict'):
                resource = Error.from_status(HTTPStatus.BAD_REQUEST, 0, "Failed validation", meta=e.message_dict)
            else:
                resource = Error.from_status(HTTPStatus.BAD_REQUEST, 0, str(e))
            return resource, resource.status, None

        except NotImplementedError:
            resource = Error.from_status(HTTPStatus.NOT_IMPLEMENTED, 0, "The method has not been implemented")
            return resource, resource.status, None

        except Exception as e:
            if self.debug_enabled:
                # If debug is enabled then fallback to the frameworks default
                # error processing, this often provides convenience features
                # to aid in the debugging process.
                raise

            resource = None
            # Fallback to the default handler
            if resource is None:
                resource = self.handle_500(request, e)

            return resource, resource.status, None

        else:
            return resource, None, None
962658
def make_request(self, handle, value, timeout=DEFAULT_TIMEOUT, with_response=True):
        """"""
        try:
            with self:
                _LOGGER.debug("Writing %s to %s with with_response=%s", codecs.encode(value, 'hex'), handle, with_response)
                self._conn.writeCharacteristic(handle, value, withResponse=with_response)
                if timeout:
                    _LOGGER.debug("Waiting for notifications for %s", timeout)
                    self._conn.waitForNotifications(timeout)
        except btle.BTLEException as ex:
            _LOGGER.debug("Got exception from bluepy while making a request: %s", ex)
            raise
545266
def dispatch(self, request, *args, **kwargs):
        

        self.return_url = request.GET.get('return_url', None)
        referrer = request.META.get('HTTP_REFERER', None)

        # leave alone POST and ajax requests and if return_url is explicitly left empty
        if (request.method != "GET" or
                request.is_ajax() or
                self.return_url or
                referrer is None or
                self.return_url is None and 'return_url' in request.GET):
            return super().dispatch(request, *args, **kwargs)

        if not self.return_url:
            url = request.get_full_path()
            if url.find("?") < 0:
                url = "?return_url=".join((url, referrer))
            else:
                url = "&return_url=".join((url, referrer))
            return HttpResponseRedirect(url)
693647
def dispatch!
      invoke do
        static! if settings.static? && (request.get? || request.head?)
        filter! :before
        route!
      end
    rescue ::Exception => boom
      invoke { handle_exception!(boom) }
    ensure
      filter! :after unless env['sinatra.static_file']
    end
826255
def request(self, *args, **kwargs):
        
        return RequestsHandler(*args, api_token=self.api_token,
                               verify=self.mist_client.verify,
                               job_id=self.mist_client.job_id, **kwargs)
921422
def dispatch(self, request, **kwargs):
        '''
        
        '''

        # Delete method must happen with POST not with GET
        if request.method == 'POST':
            # Check if this is a webservice request
            self.__authtoken = (bool(getattr(self.request, "authtoken", False)))
            self.json_worker = self.__authtoken or (self.json is True)
            # Call the base implementation
            return super(GenDelete, self).dispatch(request, **kwargs)
        else:
            json_answer = json.dumps({
                'error': True,
                'errortxt': _('Method not allowed, use POST to delete or DELETE on the detail url'),
                })
            return HttpResponse(json_answer, content_type='application/json')
1169329
def dispatch_request(self, req):
        
        log.debug("Dispatching request: {}".format(str(req)))

        # make sure it's valid
        res = None
        try:
            req.validate()
        except MissingFieldError as e:
            res = APIMissingFieldErrorResponse(str(e))

        # dispatch the request
        if not res:
            try:
                res = req.dispatch()
            except Exception as e:
                msg = "Exception raised while dispatching request: {}".format(repr(e))
                log.exception(msg)
                res = APIGenericErrorResponse(msg)

        log.debug("Response: {}".format(str(res)))

        return res
327324
def dispatch(self, request, *args, **kwargs):
        
        allowed_methods = self.get_allowed_methods()
        try:
            if request.method == 'GET' and 'GET' in allowed_methods:
                if 'pk' in request.GET or self.slug_field in request.GET:
                    return self.ng_get(request, *args, **kwargs)
                return self.ng_query(request, *args, **kwargs)
            elif request.method == 'POST' and 'POST' in allowed_methods:
                return self.ng_save(request, *args, **kwargs)
            elif request.method == 'DELETE' and 'DELETE' in allowed_methods:
                return self.ng_delete(request, *args, **kwargs)
        except self.model.DoesNotExist as e:
            return self.error_json_response(e.args[0], 404)
        except NgMissingParameterError as e:
            return self.error_json_response(e.args[0])
        except JSONResponseException as e:
            return self.error_json_response(e.args[0], e.status_code)
        except ValidationError as e:
            if hasattr(e, 'error_dict'):
                return self.error_json_response('Form not valid', detail=e.message_dict)
            else:
                return self.error_json_response(e.message)

        return self.error_json_response('This view can not handle method {0}'.format(request.method), 405)
455839
function dispatch(req, done) {
      var site = req.site
        , path = upath.join(site.path || '', req.path)
        , parent = site.parent;
      while (parent) {
        path = upath.join(parent.path || '', path);
        parent = parent.parent;
      }
      
      console.log('# ' + path);
      
      var page = new Page(path, req.context);
      pages.push(page);
      
      page.once('close', done);
      //page.site = self;
      //page.pages = pages;
      self.handle(page);
    }
530452
def dispatch(self, request, *args, **kwargs):
        
        self.args = args
        self.kwargs = kwargs
        request = self.initialize_request(request, *args, **kwargs)
        self.request = request
        self.headers = self.default_response_headers  # deprecate?

        try:
            self.initial(request, *args, **kwargs)

            # Get the appropriate handler method
            if request.method.lower() in self.http_method_names:
                handler = getattr(self, request.method.lower(),
                                  self.http_method_not_allowed)
            else:
                handler = self.http_method_not_allowed

            response = handler(request, *args, **kwargs)

        except Exception as exc:
            response = self.handle_exception(exc)

        self.response = self.finalize_response(request, response, *args, **kwargs)
        return self.response
490920
def request(self, method, url, url_params=empty.dict, headers=empty.dict, timeout=None, **params):
        """"""
        raise NotImplementedError("Concrete services must define the request method")
220318
def _fetch(self, request):
        
        client = self.client

        #: Dispatch the async call
        call = Call(__id__=client.newCall(request.request))
        call.enqueue(request.handler)

        #: Save the call reference
        request.call = call
1045990
def _create_get_request(self, resource, billomat_id='', command=None, params=None):
        
        if not params:
            params = {}

        if not command:
            command = ''
        else:
            command = '/' + command

        assert (isinstance(resource, str))
        if billomat_id:
            assert (isinstance(billomat_id, int) or isinstance(billomat_id, str))

            if isinstance(billomat_id, int):
                billomat_id = str(billomat_id)
        response = self.session.get(
            url=self.api_url + resource + ('/' + billomat_id if billomat_id else '') + command,
            params=params,
        )

        return self._handle_response(response)
507898
def dispatch(self, request, *args, **kwargs):
        
        ajax_kwargs = {'mandatory': self.ajax_mandatory}
        if self.json_encoder:
            ajax_kwargs['cls'] = self.json_encoder

        return ajax(**ajax_kwargs)(super(
            AJAXMixin, self).dispatch)(request, *args, **kwargs)
165398
public static function dispatch()
    {
        $uri = strtok($_SERVER["REQUEST_URI"],'?');
        $qs = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
        $method = $_SERVER['REQUEST_METHOD'];
        
        
        foreach (self::$routes as $name=>$route) {


            $route  = self::parsePattern($route);

            $matched = array();
            if ($route=='' || preg_match('#' . $route . '#', $uri, $matched) && (self::$methods[$name] == 'ANY' || self::$methods[$name] == $method)) {
                
                array_shift($matched);

                if (self::$qs[$name]!='' && preg_match('#' . self::$qs[$name] . '#', $qs, $qsmatched)) {

                    array_shift($qsmatched);

                    $matched = array_merge($matched, $qsmatched);
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);

                } elseif (self::$qs[$name] == '') {
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);
                }
            }

        }

        //call missing if needed
        if (!is_null(self::$missing_callback) ) {
            $diff = array_diff(self::$tocatch, self::$catched);
            if (count($diff) >= count(self::$tocatch)) {
                call_user_func(self::$missing_callback);
                BurpEvent::listen('missing', self::$callbacks[$name]);
                BurpEvent::fire('missing');

            }

        }

        BurpEvent::flushAll();
    }
1060389
def dispatch(self, request, *args, **kwargs):
        
        self.request = request
        self.args = args
        self.kwargs = kwargs

        if not self.can_view(request.user):
            raise http.Http404

        return super(CMSView, self).dispatch(request, *args, **kwargs)