Skip to content

Instantly share code, notes, and snippets.

@MiraLak
Created May 31, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiraLak/fc187ed3a25d7de5d1e6 to your computer and use it in GitHub Desktop.
Save MiraLak/fc187ed3a25d7de5d1e6 to your computer and use it in GitHub Desktop.
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