/**
  * Validate a given rule against a route and request.
  *
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $regex = $route->getCompiled()->getHostRegex();
     if (is_null($regex)) {
         return true;
     }
     return preg_match($regex, $request->getHost());
 }
 /**
  * Setup the Controller's parameters and method name.
  *
  * @param \Routing\Route $route
  * @return void
  */
 protected function setupController(Route $route, Request $request)
 {
     $action = $route->getAction();
     if (isset($action['controller'])) {
         list($class, $method) = explode('@', $action['controller']);
         $this->method = $method;
     }
     $this->params = $route->getParams();
 }
 /**
  * Add the route to any look-up tables if necessary.
  *
  * @param  \Routing\Route  $route
  * @return void
  */
 protected function addLookups($route)
 {
     $action = $route->getAction();
     if (isset($action['as'])) {
         $this->nameList[$action['as']] = $route;
     }
     if (isset($action['controller'])) {
         $this->addToActionList($action, $route);
     }
 }
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if ($route->httpOnly()) {
         return !$request->secure();
     } else {
         if ($route->secure()) {
             return $request->secure();
         }
     }
     return true;
 }
Esempio n. 5
0
 public function test()
 {
     $request = Request::instance();
     $uri = 'demo/test/{param1?}/{param2?}/{param3?}/{slug?}';
     //
     $route = new Route('GET', $uri, function () {
         echo 'Hello, World!';
     });
     $route->where('slug', '(.*)');
     // Match the Route.
     if ($route->matches($request)) {
         $route->bind($request);
         $content = '<pre>Route matched!</pre>';
     } else {
         $content = '<pre>Route not matched!</pre>';
     }
     $content .= '<pre>' . htmlspecialchars(var_export($route, true)) . '</pre>';
     return View::make('Default')->shares('title', __d('demos', 'Test'))->with('content', $content);
 }
 /**
  * Parse the given filter and options.
  *
  * @param  \Closure|string  $filter
  * @param  array  $options
  * @return array
  */
 protected function parseFilter($filter, array $options)
 {
     $parameters = array();
     $original = $filter;
     if ($filter instanceof Closure) {
         $filter = $this->registerClosureFilter($filter);
     } else {
         if ($this->isInstanceFilter($filter)) {
             $filter = $this->registerInstanceFilter($filter);
         } else {
             list($filter, $parameters) = Route::parseFilter($filter);
         }
     }
     return compact('original', 'filter', 'parameters', 'options');
 }
Esempio n. 7
0
 /**
  * @param Route $route
  */
 private function process(Route $route, Request $request)
 {
     $this->dispatch('process.before', [$request]);
     $arguments = $route->getArguments();
     array_unshift($arguments, $request);
     try {
         $response = call_user_func_array($route->getCallable(), $arguments);
         if (!$response instanceof Response) {
             $response = new Response($response);
         }
         $response->send();
     } catch (HttpException $e) {
         throw $e;
     } catch (\Exception $e) {
         throw new HttpException(500, null, $e);
     }
 }
 /**
  * Get the scheme for the given route.
  *
  * @param  \Routing\Route  $route
  * @return string
  */
 protected function getRouteScheme($route)
 {
     if ($route->httpOnly()) {
         return $this->getScheme(false);
     } else {
         if ($route->httpsOnly()) {
             return $this->getScheme(true);
         }
     }
     return $this->getScheme(null);
 }
Esempio n. 9
0
<?php

use Routing\Route;
Route::get('/', 'ExampleController@index');
Route::get('/abc', 'ExampleController@index');
Route::get('/a', 'ExampleController@index1');
Esempio n. 10
0
<?php

use Routing\Route;
Route::get('/', 'ViewController@index');
Route::get('/profile', 'ViewController@profile');
Route::get('/auth', 'UserController@auth');
Route::post('/login', 'UserController@login');
Route::post('/register', 'UserController@register');
Route::get('/name', 'UserController@getName');
Route::get('/logout', 'UserController@logout');
Route::get('/dangky', 'ViewController@getRegisterView');
Route::get('/dangnhap', 'ViewController@getLoginView');
Route::get('/data', 'NewsController@getLatestNews');
Route::get('/chitiet', 'ViewController@getDetails');
Route::get('/hotview', 'ViewController@getHotViews');
Route::get('/tintuc', 'ViewController@getNews');
Route::post('/profile/edit/password', 'UserController@postUserEditPassword');
Route::post('/profile/edit/information', 'UserController@postUserEditInfor');
Esempio n. 11
0
<?php

/**
 * Created by IntelliJ IDEA.
 * User: max
 * Date: 19-Dec-15
 * Time: 16:50
 */
use routing\Route;
return [Route::get("scripts/:script", "Script|get")->setConstraints(["script" => ".+"]), Route::get("model/:x/:y/:z", "Model|get"), Route::get(":page", "Index")->setConstraints(["page" => ".+"])];
Esempio n. 12
0
 /**
  * Call the given route's before filters.
  *
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @param  \Http\Response  $response
  * @return mixed
  */
 public function callRouteAfter($route, $request, $response)
 {
     foreach ($route->afterFilters() as $filter => $parameters) {
         $this->callRouteFilter($filter, $parameters, $route, $request, $response);
     }
 }
Esempio n. 13
0
 /**
  * @param Route $route
  */
 private function process(Route $route, Request $request)
 {
     $arguments = $route->getArguments();
     array_unshift($arguments, $request);
     try {
         $contentResponse = call_user_func_array($route->getCallable(), $arguments);
         //~ http_response_code($this->statusCode);
         //~ echo $response;
         $response = new Response($contentResponse, $this->statusCode);
         $response->send();
     } catch (HttpException $e) {
         throw $e;
     } catch (\Exception $e) {
         throw new HttpException(500, null, $e);
     }
 }
 /**
  * Apply the applicable after filters to the route.
  *
  * @param  \Routing\Controller  $instance
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @param  string  $method
  * @return mixed
  */
 protected function assignAfter($instance, $route, $request, $method)
 {
     foreach ($instance->getAfterFilters() as $filter) {
         if ($this->filterApplies($filter, $request, $method)) {
             $route->after($this->getAssignableAfter($filter));
         }
     }
 }
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $regex = $route->getCompiled()->getRegex();
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     return preg_match($regex, rawurldecode($path));
 }
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     return in_array($request->getMethod(), $route->methods());
 }