Gestion du téléchargement par requete POST
This commit is contained in:
parent
629e088588
commit
ed5e48091e
|
@ -35,6 +35,15 @@
|
|||
"markdown": {
|
||||
"description": "Retourne une description en markdown des différents modules de l'API",
|
||||
"permissions": [],
|
||||
"options": { "download": true },
|
||||
"parameters": {}
|
||||
},
|
||||
|
||||
|
||||
"apiBlueprint": {
|
||||
"description": "Retourne une documentation de l'API au format API Blueprint.",
|
||||
"permissions": [],
|
||||
"options": { "download": true },
|
||||
"parameters": {}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -100,9 +100,12 @@
|
|||
// Api
|
||||
$R->post('api(?:/(.*))?', function($url){
|
||||
$request = ModuleRequest::fromPost($url, $_POST);
|
||||
$answer = $request->dispatch();
|
||||
$answer = $request->dispatch();
|
||||
|
||||
// Si c'est une réponse
|
||||
if( $answer instanceof ModuleResponse )
|
||||
echo $answer->serialize();
|
||||
|
||||
echo $answer->serialize();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@
|
|||
/* (2) On affiche le contenu */
|
||||
echo $returned['body'];
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,23 +49,23 @@
|
|||
|
||||
/* [2] Mise en forme de la liste des modules
|
||||
=========================================================*/
|
||||
$markdown = "## Module List<br>";
|
||||
$markdown = "## Module List\n";
|
||||
|
||||
foreach($modules as $moduleName=>$moduleData)
|
||||
$markdown .= "- $moduleName<br>";
|
||||
$markdown .= "- $moduleName\n";
|
||||
|
||||
/* [3] Mise en forme des méthodes des modules
|
||||
=========================================================*/
|
||||
$markdown .= '----<br>## Method List & Description<br>';
|
||||
$markdown .= "----\n## Method List & Description\n";
|
||||
|
||||
$count = 1;
|
||||
foreach($modules as $moduleName=>$moduleData){
|
||||
$markdown .= "### $count - '$moduleName' methods<br>";
|
||||
$markdown .= "### $count - '$moduleName' methods\n";
|
||||
|
||||
foreach($moduleData as $methodName=>$methodData)
|
||||
$markdown .= "`$methodName` - ".$methodData['description']."<br>";
|
||||
$markdown .= "`$methodName` - ".$methodData['description']."\n";
|
||||
|
||||
$markdown .= '----<br>';
|
||||
$markdown .= "----\n";
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
@ -76,12 +76,69 @@
|
|||
=========================================================*/
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'markdown' => $markdown
|
||||
'headers' => array(
|
||||
'Content-Type' => 'text/markdown; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
'body' => $markdown
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* RENVOIE UNE DOC API_BLUEPRINT DE L'API
|
||||
*
|
||||
* @return apiBlueprint<String> Description des modules au format API Blueprint
|
||||
*
|
||||
*/
|
||||
public static function apiBlueprint(){
|
||||
/* [1] Récupération de la configuration
|
||||
=========================================================*/
|
||||
// On récupère le fichier et on le parse
|
||||
$modules = json_decode( ResourceDispatcher::getResource('f/json/modules/conf'), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $modules == null )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
|
||||
|
||||
|
||||
/* [2] Pour chaque module
|
||||
=========================================================*/
|
||||
$content = '';
|
||||
foreach($modules as $module=>$methods){
|
||||
|
||||
$content .= "## $module [/$module] \n\n";
|
||||
|
||||
/* [3] Pour chaque méthode
|
||||
=========================================================*/
|
||||
foreach($methods as $methName=>$method){
|
||||
$content .= "### $methName [POST /$module/$methName]\n\n";
|
||||
$content .= $method['description']."\n";
|
||||
if( count($method['permissions']) > 0)
|
||||
$content .= '> Permissions `'.implode('`', $method['permissions'])."`\n\n";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => array(
|
||||
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
'body' => $content
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue