Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Accelerometer to Cassandra REST Api
@RestController
@RequestMapping("/acceleration")
public class AccelerationController {
private static final Logger log = LoggerFactory.getLogger(AccelerationController.class);
@Autowired
private CassandraOperations cassandraTemplate; //contains Operations for interacting with Cassandra.
@RequestMapping(method = POST, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity newAcceleration(@RequestBody @Valid AccelerartionModel accelerationModel) {
Acceleration acceleration = new Acceleration(accelerationModel);
if (log.isInfoEnabled()) {
log.info("/POST /acceleration with values {}", acceleration);
}
// insert values into CassandraDB and return 201 HTTP code
cassandraTemplate.insert(acceleration);
return status(CREATED).build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.