RestApiServer (Dev)
Description
The REST API Server allows modules to expose REST APIs over HTTP.
Services Provided
- IRestApiService
Service Dependencies
None.
Java File
The module is implemented in net.floodlightcontroller.restserver.RestApiServer.
How it works
The Rest API server uses the Restlets library. More documentation on Restlet is available here. Other modules that have the REST server as a dependency expose APIs through adding a class that implements RestletRoutable. Each RestletRoutable contains a Router that attaches Restlet resources (the most common being ServerResource). Users will attach their own classes that extend a Restlet resource in order to handle requests for specific URLs. Inside the resource annotations such as @Get, @Put, etc are to select which method will be used for HTTP requests. Serialization is done via the Jackson library that is included in the Restlet library. Jackson can serialize objects in two ways. One is that it will automatically use available getters on objects serialize those fields. Otherwise custom serializers can be created and annotated on the top of the class.
Limitations
- Base paths can not overlap and must be unique.
- Restlets can only access module data via service interfaces. If a module needs to expose data via the REST server it has to expose an interface to get this data.
Configuration
The module is enabled by default, no change to the configuration is required to load the module.
Configuration Options
Name |
Type |
Default |
Description |
---|---|---|---|
port |
Int |
8080 |
The TCP port to listen on for HTTP connections. |
REST API
None.