2017 © Pedro Peláez
 

library hx-route

HTTP REST router

image

guinso/hx-route

HTTP REST router

  • Saturday, July 2, 2016
  • by guinso
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

hx-route

Simple HTTP routing utility. Can use for REST handler., (*1)

Install Package

Composer

//for PHP 7
{
  "require": {
    "guinso/hx-route": "2.0.*"
  }
}

//for PHP 5
{
  "require": {
    "guinso/hx-route": "1.0.*"
  }
}

Manual

require_once("hx-route-directory/src/autoloader.php");

Example

// method options: GET, POST, PUT, DELETE, or any standard HTTP method
//$inputData specification can read from hx-http
//$inputData = array(
//    "data" => ....  client input value
//   "file" => ... client upload file path value
//);
$routeConfigure = array(
    new \Hx\Route\Info("/your/customer/(\w+)", "GET", function($arg, $inputData) {
        $urlArgument = $arg[0]; //this is value from URL argument (\w+)

        //get general value
        $clientSpecificKeyValue = $inputData["date"]["clientSpecificKey"];

        //get temporary uploaded file path
        $clientUploadFilePath = $inputData["file"]["clientSpecificFileName"];
    },

    new \Hx\Route\Info("/another/custom/path", "POST", function($arg, $inputData) {
        //handle another request
    }
);

//initialize URL routing handler
$router = new \Hx\Route\RestRouter(
  new \Hx\Route\Mapper($routeConfigure), 
  new \Hx\Http\HeaderReader(), 
  new \Hx\Http\InputService());

$router->run(); //start process incoming request URL

The Versions

02/07 2016

dev-master

9999999-dev

HTTP REST router

  Sources   Download

MIT

The Requires

 

http

02/07 2016

2.0.0

2.0.0.0

HTTP REST router

  Sources   Download

MIT

The Requires

 

http

13/12 2015

1.0.1

1.0.1.0

HTTP REST router

  Sources   Download

MIT

The Requires

 

http

13/12 2015

1.0.0

1.0.0.0

HTTP REST router

  Sources   Download

MIT

The Requires

 

http