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)
|
||||
- [**2** Complex Types](#2---complex-types)
|
||||
|
||||
[**VI.** Documentation](#vi-documentation)
|
||||
|
||||
- [**1** API accessible documentation](#1---api-accessible-documentation)
|
||||
|
||||
|
||||
# **I.** Overview
|
||||
## **1** Introduction & features
|
||||
|
@ -411,4 +415,14 @@ 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.
|
||||
|
||||
**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": {
|
||||
|
@ -13,12 +13,11 @@
|
|||
}
|
||||
},
|
||||
|
||||
"/api/{module}/{method}{url_arguments}": {
|
||||
"/api/v/1.0/{uri}": {
|
||||
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
||||
"controller": "api:call",
|
||||
"arguments": {
|
||||
"module": "[a-zA-Z_]+",
|
||||
"method": "[a-zA-Z_]+",
|
||||
"url_arguments": "(\\/[\\w:-]+)*\\/?"
|
||||
"uri": ".*"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use \api\core\Request;
|
||||
use \api\core\Response;
|
||||
use \api\core\Loader;
|
||||
|
||||
|
||||
class api{
|
||||
|
@ -17,11 +18,13 @@
|
|||
*
|
||||
*/
|
||||
public function __construct($matches){
|
||||
|
||||
/* (1) Rebuild request url */
|
||||
$url = $matches['module'].'/'.$matches['method'].$matches['url_arguments'];
|
||||
$uri = $matches['uri'];
|
||||
|
||||
/* (2) Creates request */
|
||||
$this->request = Request::remote($url, $_POST);
|
||||
$this->request = Loader::remote($uri);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +32,7 @@
|
|||
*
|
||||
*/
|
||||
public function call(){
|
||||
|
||||
/* (1) Process response */
|
||||
$this->response = $this->request->dispatch();
|
||||
|
||||
|
@ -37,6 +41,7 @@
|
|||
echo $this->response->serialize();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/* POST-CALL
|
||||
|
|
Loading…
Reference in New Issue