REST API Server
As you can see in the sample application, Jet makes it very easy to create a REST API server. Implementing a REST API server is not difficult in Jet. In fact, the server just ties together what Jet can do on its own. That is, it takes advantage of the features of the ORM DataModel, forms, other bits and pieces, and the overall Jet architecture.
Hence, the Jet\RESTServer class set is very small indeed - almost minimalistic.
In the sample application, there are two modules that are examples of REST APIs, namely Content.Articles.REST and Content.Images.REST. These modules make full use of Jet MVC. Thus, a base is created for the REST API Server. The Modules to this base define MVC pages, which in this case are the REST API endpoints. And then it's all up to the controllers. Thus, the REST API itself is represented in the sample application by the JetApplicationModule\Content\Articles\REST\Controller_Main and JetApplicationModule\Content\Images\REST\Controller_Main classes.
In particular, the first named controller - a sample REST API for managing articles - is very simple. If you haven't already, check out the class. The main thing is the microrouter controller - that is, determining controller operations/actions based on a REST HTTP request. The individual controller actions follow, but it's an exaggeration to say that logging operations takes the most code. Everything else is just using what Jet can already do.
So don't expect any miracles from Jet\RESTServer anymore. It's a really simple connection of everything else. By the way, you probably noticed that the sample controllers inherit from the Jet\MVC_Controller_REST class, and if you look at this class, you will again find only a few lines of code referring to Jet\RESTServer.
Jet\RESTServer consists of only three classes:
- Jet\RESTServer
A façade consisting of static methods through which to work with RESTServer and which uses a replaceable backend (i.e., dependency insertion) - a classic Jet architecture approach. That is, you can of course change how Jet handles requests and how it creates responses according to your needs while maintaining a unified API subsystem. - Jet\RESTServer_Backend
Interface defining the backend. - Jet\RESTServer_Backend_Default
Default backend.