Module: Rest - ninazeina/SXP GitHub Wiki
REST (Representational State Transfer) is an architecture style based on HTTP. It uses HTTP verbs (GET, POST, PUT, DELETE, etc.) to interact with the client.
Role
See also CommandLine.
The rest module starts up a RestServer
that listens to the requests of the client html5-based GUI.
It passes them on to the methods of some other module, provided that they are annotated in the right way. By default this is the controller module. Each request is then linked to a controller method depending on its HTTP verb and uri
.
Currently, the rest module uses Jetty as a rest server implementation and javax.ws.rs as a restfull interface.
Main classes
-
rest.impl.JettyRestServer
is the implementation of therest.api.RestServer
interface. Its instanciation is done directly by the application. The initialization is done on the controller module. A servlet is then associated with each class of this module that contains a@ServletPath
annotation (i.e.controller.Items
,controller.Users
andcontroller.Search
). The methods of thoses classes are called by the rest server according to its HTTP verb and path annotation. -
rest.impl.SimpleAuthentifier
is the implementation of therest.api.Authentifier
interface. A restful interface does not save any data between two requests. That is the reason why one needs to instantiate a user authentifier at the application level. The authentification is done by a unique random token associated with the user id and its password.