-
-
Save MiraLak/fc187ed3a25d7de5d1e6 to your computer and use it in GitHub Desktop.
Accelerometer to Cassandra REST Api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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