Développer un service web permettant d'enregistrer des recettes.
Ajout
duration est un entier qui représente des minutes. ingredients et steps sont des tableaux de string.POST /recipes
Content-Type: application/json
{
name: ...,
?description: ...,
?ingredients: ...,
?steps: ...,
?duration: ...
}
===
201
Content-Type: application/json
{
id: ...
name: ...,
description: ...,
ingredients: ...,
steps: ...,
duration: ...
}
~~~ Validation
400
Content-Type: text/plain
"Erreur..."XXhYYGET /recipes
===
Content-Type: application/json
[
{
id: ...,
name: ...,
description: ...,
ingredients: [...],
steps: [...],
duration: "XXhYY"
},
...
]DELETE /recipes/:id
===
204
~~~ Id invalide
404
Content-Type: text/plain
"Invalid id"À partir de l'exercice Recipeasy précédent, ajouter la gestion de plusieurs usagers et l'authentification.
ROUTE
Authorization: Basic ...
...
~~~ Si authentification invalide
401
WWW-Authenticate: BasicGET /recipes/:id
Accept: application/json | application/yaml
===
200
Content-Type: ...
...Données...
~~~ Format invalide
400
Content-Type: text/plain
"Invalid format"
~~~ Id invalide
404
Content-Type: text/plain
"Invalid id"Développer une application Sinatra permettant de convertir du contenu json, xml ou yaml vers l'un ou l'autre de ces formats. Compléter ce client qui utilisera les informations de l'utilisateur pour envoyer la requête de conversion au serveur.
Content-Type et Accept
application/json, application/xml, application/yamlContent-TypeImporter le fichier converty.rb dans votre application serveur et exploiter les fonctions de conversion fournies
Converty::Json::to_json("le contenu a convertir")
Converty::Json::to_xml("le contenu a convertir")
Converty::Json::to_yaml("le contenu a convertir")
Converty::Xml::to_json("le contenu a convertir")
Converty::Xml::to_xml("le contenu a convertir")
Converty::Xml::to_yaml("le contenu a convertir")
Converty::Yaml::to_json("le contenu a convertir")
Converty::Yaml::to_xml("le contenu a convertir")
Converty::Yaml::to_yaml("le contenu a convertir")Ces fichiers vous permettront de tester vos programmes
POST /
Content-Type: ...
Accept: ...
...Contenu a convertir...
===
200
Content-Type: ...
...Contenu converti...
~~~
400
Content-Type: ...
...Erreur...Enter filename: airport.xml
Enter output type (json, xml, yaml): json
{"flight":[{"plane":"A380","number":"F9876","origin":"canada","destination":"usa","departure":"2022-03-12 11
:34","pilot":[{"firstname":"alice","lastname":"smith"}]},{"plane":"B737","number":"K2038","origin":"france",
"destination":"mexico","departure":"2020-09-21 17:35","pilot":[{"firstname":"bob","lastname":"jones"}]},{"pl
ane":"B747","number":"E3957","origin":"spain","destination":"france","departure":"2021-06-14 21:47","pilot":
[{"firstname":"charlie","lastname":"anderson"}]},{"plane":"A330","number":"M2775","origin":"usa","destinatio
n":"canada","departure":"2020-01-19 06:12","pilot":[{"firstname":"alice","lastname":"smith"}]},{"plane":"A38
0","number":"T3845","origin":"italy","destination":"france","departure":"2022-03-04 19:28","pilot":[{"firstn
ame":"bob","lastname":"jones"}]}]}etd@vm: ruby client.rb recipes.json xml
<opt>
<anon name="Club sandwich" description="Pain garni de poulet avec condiments" category="repas">
<ingredients>pain</ingredients>
<ingredients>poulet</ingredients>
<ingredients>bacon</ingredients>
<ingredients>laitue</ingredients>
<ingredients>tomate</ingredients>
<ingredients>mayonnaise</ingredients>
<steps>Cuire et couper le poulet</steps>
<steps>Assembler la sandwich</steps>
</anon>
<anon name="Fromage" description="Produit laitier" category="collation" />
<anon name="Canapé de saumon fumé" description="Biscuit de blé garni de saumon fumé" category="entrée">
<ingredients>Filet de saumon fumé</ingredients>
<ingredients>Biscuits de blé</ingredients>
<ingredients>Fromage Brie</ingredients>
<steps>Assembler le canapé</steps>
</anon>
<anon name="Crème de brocoli" description="Crème de brocoli cheddar bacon" category="entrée">
<ingredients>brocoli</ingredients>
<ingredients>crème</ingredients>
<ingredients>cheddar</ingredients>
<ingredients>bacon</ingredients>
<steps>Cuire le brocoli</steps>
<steps>Mélanger au robot avec la crème</steps>
<steps>Servir dans un bol</steps>
<steps>Garnir de minces tranches de cheddar et bacon haché</steps>
</anon>
</opt>