updated router.config + router.controller.api + updated notice.api:3.0 (added Documentation data)
This commit is contained in:
parent
5052032204
commit
99065e37c7
|
@ -51,6 +51,10 @@ Plan
|
||||||
- [**1** Default Types](#1---default-types)
|
- [**1** Default Types](#1---default-types)
|
||||||
- [**2** Complex Types](#2---complex-types)
|
- [**2** Complex Types](#2---complex-types)
|
||||||
|
|
||||||
|
[**VI.** Documentation](#vi-documentation)
|
||||||
|
|
||||||
|
- [**1** API accessible documentation](#1---api-accessible-documentation)
|
||||||
|
|
||||||
|
|
||||||
# **I.** Overview
|
# **I.** Overview
|
||||||
## **1** Introduction & features
|
## **1** Introduction & features
|
||||||
|
@ -412,3 +416,13 @@ To add a new type, just open the file `/build/api/Checker.php` and add an entry
|
||||||
> **Note:** It is possible to chain `array` type as many as needed.
|
> **Note:** It is possible to chain `array` type as many as needed.
|
||||||
|
|
||||||
**Ex.:** `array<array<id>>` - Will only match an array containing arrays that only contains `id` entries.
|
**Ex.:** `array<array<id>>` - Will only match an array containing arrays that only contains `id` entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# **VI.** Documentation
|
||||||
|
|
||||||
|
With the *all-in-config* method, we can generate a consistent documentation or other documents from the `/config/modules.json` file.
|
||||||
|
|
||||||
|
## **1** - API accessible documentation
|
||||||
|
|
||||||
|
You can request the API for information about the current URI by using the `OPTIONS` HTTP method.
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
"methods": [ "GET", "POST", "PUT", "DELETE" ],
|
"methods": [ "GET", "POST", "PUT", "DELETE", "OPTIONS" ],
|
||||||
|
|
||||||
|
|
||||||
"routes": {
|
"routes": {
|
||||||
|
@ -13,12 +13,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"/api/{module}/{method}{url_arguments}": {
|
"/api/v/1.0/{uri}": {
|
||||||
|
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
||||||
"controller": "api:call",
|
"controller": "api:call",
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"module": "[a-zA-Z_]+",
|
"uri": ".*"
|
||||||
"method": "[a-zA-Z_]+",
|
|
||||||
"url_arguments": "(\\/[\\w:-]+)*\\/?"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use \api\core\Request;
|
use \api\core\Request;
|
||||||
use \api\core\Response;
|
use \api\core\Response;
|
||||||
|
use \api\core\Loader;
|
||||||
|
|
||||||
|
|
||||||
class api{
|
class api{
|
||||||
|
@ -17,11 +18,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($matches){
|
public function __construct($matches){
|
||||||
|
|
||||||
/* (1) Rebuild request url */
|
/* (1) Rebuild request url */
|
||||||
$url = $matches['module'].'/'.$matches['method'].$matches['url_arguments'];
|
$uri = $matches['uri'];
|
||||||
|
|
||||||
/* (2) Creates request */
|
/* (2) Creates request */
|
||||||
$this->request = Request::remote($url, $_POST);
|
$this->request = Loader::remote($uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +32,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function call(){
|
public function call(){
|
||||||
|
|
||||||
/* (1) Process response */
|
/* (1) Process response */
|
||||||
$this->response = $this->request->dispatch();
|
$this->response = $this->request->dispatch();
|
||||||
|
|
||||||
|
@ -37,6 +41,7 @@
|
||||||
echo $this->response->serialize();
|
echo $this->response->serialize();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* POST-CALL
|
/* POST-CALL
|
||||||
|
|
Loading…
Reference in New Issue