You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/org.restlet.tutorial.webapi/README.md
+57-74Lines changed: 57 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,12 @@
6
6
7
7
* Git installed on your machine
8
8
9
-
> The implementation is located [here](https://github.com/restlet/restlet-tutorial/tree/master/modules/org.restlet.tutorial.webapi)
10
-
> You can clone this repository; the source code is located in `/modules/org.restlet.tutorial.webapi/` folder.
9
+
The implementation is located [here](https://github.com/restlet/restlet-tutorial/tree/master/modules/org.restlet.tutorial.webapi). You can clone this repository; the source code is located in `/modules/org.restlet.tutorial.webapi/` folder.
11
10
12
-
> This example uses [Restlet Framework 2.3.0](http://restlet.com/download/current#release=stable&edition=jse&distribution=zip) (Java SE edition)
13
-
and [H2 Database](www.h2database.com)
11
+
This example uses [Restlet Framework 2.3.0](http://restlet.com/download/current) (Java SE edition)
12
+
and [H2 Database](www.h2database.com).
14
13
15
-
> Restlet framework user guide is available [here](http://restlet.com/technical-resources/restlet-framework/guide/2.3/).
14
+
Restlet Framework's User Guide is available [here](http://restlet.com/technical-resources/restlet-framework/guide/2.3/).
16
15
17
16
## Installation
18
17
@@ -23,7 +22,7 @@ To install the Maven project:
23
22
* Execute `mvn clean install`
24
23
* For eclipse users : run `mvn eclipse:eclipse`
25
24
26
-
> For further instruction about running a Maven project : [Building a project with Maven](http://maven.apache.org/run-maven/index.html)
25
+
For further instruction about running a Maven project : [Building a project with Maven](http://maven.apache.org/run-maven/index.html)
27
26
28
27
### Run this application
29
28
@@ -36,34 +35,31 @@ Two files will be created :
36
35
37
36
They are both located in `/tmp` folder.
38
37
To simplify the launch of the application, authentication and authorization are done in-memory
39
-
(You should overwrite that with you own authentication system). Here are the login/password available:
38
+
(You should overwrite that with your own authentication system). Here are the login/password available:
40
39
41
40
* admin/admin : to get admin role
42
41
* owner/owner : to get owner role
43
42
* user/user : to get user role
44
43
45
-
It uses HTTP Basic authentication.
44
+
It uses HTTP Basic authentication. Learn more about authentication, authorization and security with Restlet Framework [here](http://restlet.com/learn/guide/2.3/core/security/).
46
45
47
-
> Learn more about authentication, authorization and security with Restlet Framework [here](http://restlet.com/learn/guide/2.3/core/security/).
48
-
49
-
> You can try this application easily with a REST client like [POSTMAN](http://www.getpostman.com/).
46
+
You can interact with this application easily using a REST client like [POSTMAN](http://www.getpostman.com/).
50
47
51
48
## Database access
52
49
53
50
To visualize the database, open the H2 console in you browser (`http://localhost:8082`) and connect to the database with the JDBC URL `jdbc:h2:mem:restletWebApi;IFEXISTS=TRUE`.
54
51
55
52
## Description
56
53
57
-
This Web API contains 2 main resources :
58
-
54
+
This Web API contains 2 main resources:
59
55
* Company : identified by an auto-generated id.
60
56
* Contact : identified by its email. A contact can be part of a company and get a reference to it.
> A Web API definition can be generated with [APISpark extension (RF 2.3)](http://restlet.com/learn/guide/2.3/extensions/apispark).
62
+
A Web API definition can be generated with [APISpark extension (V2.3)](http://restlet.com/learn/guide/2.3/extensions/apispark).
67
63
68
64
## Implementation choices
69
65
@@ -76,98 +72,97 @@ This is a diagram of the API :
76
72
## Next steps
77
73
78
74
Here are some instructions to go further with this project:
79
-
80
75
* Persistence layer
81
76
* For each operation a new connection is created.
82
-
It would be useful to use a connection pool like [DBCP](http://commons.apache.org/proper/commons-dbcp/).
77
+
It would be useful to use a connection pool like [DBCP](http://commons.apache.org/proper/commons-dbcp/) or the built-in connection pool of your database's JDBC driver if available.
83
78
* It is possible to totally dissociate the persistence layer from the Server Resources.
84
-
It would allow the use of several persitence layers. It would also be possible to use dependency injection.
79
+
It would allow the use of several persistence layers. It would also be possible to use dependency injection.
85
80
* Authentication/Authorization
86
-
* It is strongly recommended to store users/roles in a database instead of in-memory.
81
+
* It is strongly recommended to store users/roles in a database or a user directory instead of in-memory.
87
82
You can create a custom [SecretVerifier](http://restlet.com/technical-resources/restlet-framework/javadocs/2.3/jse/api/org/restlet/security/SecretVerifier.html)
88
-
and [Enroler](http://restlet.com/technical-resources/restlet-framework/javadocs/2.3/jse/api/org/restlet/security/Enroler.html).
83
+
and [Enroler](http://restlet.com/technical-resources/restlet-framework/javadocs/2.3/jse/api/org/restlet/security/Enroler.html) for this purpose.
89
84
* It is possible to handle autorizations globally in a filter instead of at the beginning of each class.
90
85
In fact, in this example, there is a repeating schema: the "user" role is required for GET methods,
91
86
the "owner" role for to the others.
92
87
93
88
## Usage
94
89
95
-
> These examples are made using the JSON format but you can use XML or YAML if you want.
90
+
These examples are made using the JSON format but you can use XML or YAML if you want.
96
91
97
92
### Ping resource
98
93
99
94
A resource `/ping` has been created which does not need authentication.
It should return the ```Version: 1.0.0 running``` text in the HTTP response body.
104
99
105
-
> For the following examples, Basic Authentication is required
100
+
For the following examples, Basic Authentication is required. Also, you should indicate the media type of the JSON document sent using a ```Content-Type: application/json``` HTTP header.
> The field company is a reference to the location of the company, with 1 the id of the company.
199
-
ie : /companies/1 refers to http://localhost:9000/v1/companies/1
191
+
The property company is a reference to the location of the company, with 1 the id of the company. ie : /companies/1 refers to http://localhost:9000/v1/companies/1
200
192
201
193
### Retrieve the list of created contacts
202
194
203
195
```GET http://localhost:9000/v1/contacts```
204
196
205
-
> The trailing slash is optional : both ```http://localhost:9000/v1/contacts/``` and ```http://localhost:9000/v1/contacts``` will work.
206
-
207
-
It should retrieve :
197
+
The trailing slash is optional : both ```http://localhost:9000/v1/contacts/``` and ```http://localhost:9000/v1/contacts``` will work. It should retrieve :
0 commit comments