getRequestMethod() публичный статический Метод

Get lower-cased representation of current HTTP Request method
public static getRequestMethod ( )
Пример #1
0
 function preroute(&$req, &$res)
 {
     header("Access-Control-Allow-Origin: {$this->domain}", true);
     if (strcasecmp(Zaphpa_Router::getRequestMethod(), "options") == 0) {
         header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH", true);
         header("Access-Control-Allow-Headers: origin, x-http-method-override, accept, content-type, authorization", true);
     }
 }
Пример #2
0
 public function route($uri = null)
 {
     if (empty($uri)) {
         // CAUTION: parse_url does not work reliably with relative URIs, it is intended for fully qualified URLs.
         // Using parse_url with URI can cause bugs like this: https://github.com/zaphpa/zaphpa/issues/13
         // We have URI and we could really use parse_url however, so let's pretend we have a full URL by prepending
         // our URI with a meaningless scheme/domain.
         $tokens = parse_url('http://foo.com' . $_SERVER['REQUEST_URI']);
         $uri = rawurldecode($tokens['path']);
     }
     /* Call preprocessors on each middleware impl */
     foreach (self::$middleware as $m) {
         $m->preprocess($this);
     }
     $routes = $this->getRoutes();
     foreach ($routes as $route) {
         $params = $route['template']->match($uri);
         if (!is_null($params)) {
             Zaphpa_Middleware::$context['pattern'] = $route['template']->getTemplate();
             Zaphpa_Middleware::$context['http_method'] = self::getRequestMethod();
             Zaphpa_Middleware::$context['callback'] = $route['callback'];
             $callback = Zaphpa_Callback_Util::getCallback($route['callback'], $route['file']);
             return $this->invoke_callback($callback, $params);
         }
     }
     if (strcasecmp(Zaphpa_Router::getRequestMethod(), "options") == 0) {
         return $this->invoke_options();
     }
     throw new Zaphpa_InvalidPathException('Invalid path');
 }
Пример #3
0
 function preprocess(&$router)
 {
     if (!empty($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) && Zaphpa_Router::getRequestMethod() == "post") {
         $_SERVER['REQUEST_METHOD'] = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
     }
 }