slam4:richclient:angularjs:project:openbeerdatabase:rest

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
slam4:richclient:angularjs:project:openbeerdatabase:rest [2015/03/09 01:01] – [2.2- Brasseur correspondant à un id] jcheronslam4:richclient:angularjs:project:openbeerdatabase:rest [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1
Ligne 4: Ligne 4:
 ===== -- Connexion ===== ===== -- Connexion =====
  
-Base URL : <html><span class="rest-link">users/</span></html>+Base URL : <html><span class="rest-link">user/</span></html>
 |< 100% >| |< 100% >|
 ^URL ^Méthode ^Paramètres ^Rôle ^Réponses possibles ^ ^URL ^Méthode ^Paramètres ^Rôle ^Réponses possibles ^
Ligne 19: Ligne 19:
 {connected: false}</sxh> | {connected: false}</sxh> |
  
 +<html><div class="note"><div id="myContainer">
 +<h3>Exemple de connection avec Angular :</h3>
 +</html>
 +<sxh javascript;title:Connexion>
 +
 +data.posted={"mail":"admin@local.fr","password":"0000"};
 +this.connect(data,function(d){console.log("Connexion réussie, token : "+d.token)});
 +
 +this.connect=function(response,callBack){
 + var request = $http({
 +     method: "POST",
 +     url: restConfig.server.restServerUrl+"user/connect",
 +     data: $.param(response.posted),
 +     headers: self.headers
 + });
 + request.success(function(data, status, headers, config) {
 + callback(data);//Connexion réussie
 + }).error(function(data, status, headers, config){
 + self.addMessage({type: "warning", content:"Erreur de connexion au serveur, statut de la réponse : "+status+"<br>"+data.message});
 + });
 +}
 +</sxh>
 +<html>
 +<h3>Conserver la session (PHP) avec Angular :</h3>
 +Il suffit de décommenter la ligne <strong>withCredentials = true</strong> dans le fichier <strong>js/config.js</strong>
 +</html>
 +<sxh javascript;title:js/config.js;highlight:[3]>
 +module.exports=function($routeProvider,$locationProvider,$httpProvider) {
 + //$httpProvider.defaults.useXDomain = true;
 + $httpProvider.defaults.withCredentials = true;
 +</sxh>
 +<html></div></div></html>
 ===== -- Brasseurs ===== ===== -- Brasseurs =====
  
Ligne 247: Ligne 279:
 **Exemple de réponse :** **Exemple de réponse :**
  
-URL : <html><span class="rest-link">/beers/7</span></html>+URL : <html><span class="rest-link">/beers/1</span></html>
  
 <sxh javascript;gutter:false> <sxh javascript;gutter:false>
Ligne 265: Ligne 297:
 |< 100% >| |< 100% >|
 ^Code ^Raison ^Réponse ^ ^Code ^Raison ^Réponse ^
-|**404** | Aucune bière trouvée dans la BDD correspondant à l'id passé en paramètre |<sxh javascript;gutter:false>{"message":"Ooops! La bière est introuvable","code":404}</sxh>|+|**404** | Aucune bière trouvée dans la BDD correspondant à l'id passé en paramètre |<sxh javascript;gutter:false>{"message":"Ooops! La bière d'id '1' est introuvable","code":404}</sxh>|
  
 ==== -- Liste des bières d'une brasserie ==== ==== -- Liste des bières d'une brasserie ====
Ligne 309: Ligne 341:
 |< 100% >| |< 100% >|
 ^URL ^Méthode ^Paramètres ^data ^Rôle ^ ^URL ^Méthode ^Paramètres ^data ^Rôle ^
-|<html><span class="rest-link">/beers</span></html> |**POST** |token |<sxh javascript;gutter:false>{"name":"Fischer","url":"http://www.fischer.com"}</sxh> |Ajoute la bière postée |+|<html><span class="rest-link">/beers</span></html> |**POST** |token |<sxh javascript;gutter:false>{"name":"Brooklyn Ama Bruna modif", 
 +"description":"Brewed by Amarcord Brewery in the small medieval town of Apecchio...", 
 +"abv":"bab"}</sxh> |Ajoute la bière postée |
  
 **Exemple de réponse :** **Exemple de réponse :**
Ligne 344: Ligne 378:
 |< 100% >| |< 100% >|
 ^URL ^Méthode ^Paramètres ^data ^Rôle ^ ^URL ^Méthode ^Paramètres ^data ^Rôle ^
-|<html><span class="rest-link">/beers/:id</span></html> |**PUT** |token |<sxh javascript;gutter:false>{"name":"Brooklyn Ama Bruna modif","description":"Brewed by Amarcord Brewery in the small medieval town of Apecchio...","abv":"bab"}</sxh> |modifie la bière postée |+|<html><span class="rest-link">/beers/:id</span></html> |**PUT** |token |<sxh javascript;gutter:false>{"name":"Brooklyn Ama Bruna modif", 
 +"description":"Brewed by Amarcord Brewery in the small medieval town of Apecchio...", 
 +"abv":"bab"}</sxh> |modifie la bière postée |
  
 **Exemple de réponse :** **Exemple de réponse :**
  • slam4/richclient/angularjs/project/openbeerdatabase/rest.1425859309.txt.gz
  • Dernière modification : il y a 6 ans
  • (modification externe)