This API will be far more useful and will provide us with the ability to add data so that the current web data feed is not the only data source.
The sample code in the georestwebservice
project (of this chapter) is an updated version of the API with the new recordFeature
method in the georestwebservice.dart
file:
@ApiMethod(path: 'record', method: 'POST') QuakeResponse recordFeature(QuakeRequest request) { DaoQuakeAPI quakeAPI = new DaoQuakeAPI(); quakeAPI.recordFeature(getFeatureAsJSON(request)); QuakeResponse quakeResponse = new QuakeResponse(); quakeResponse.result = "1"; return quakeResponse; }
This method will use the standard HTTP POST
verb in order to receive the input from the client application. As the rpc
package wraps the entire method and composes and sends error responses, there is no need for error handling in this method. If, for example, something goes wrong while storing a result in the database, the client will receive an error message.
The...