feat(backend): add basic sensor endpoints
This commit is contained in:
parent
5d1d650a70
commit
7e424fe05f
@ -3,11 +3,16 @@ package org.mercury.backend;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class BackendApplication {
|
||||
|
||||
private SensorData sensorData;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BackendApplication.class, args);
|
||||
}
|
||||
@ -16,4 +21,15 @@ public class BackendApplication {
|
||||
public String hello() {
|
||||
return String.format("Server up and running!");
|
||||
}
|
||||
|
||||
@PostMapping("/sensor")
|
||||
SensorData newEmployee(@RequestBody SensorData sensorData) {
|
||||
this.sensorData = sensorData;
|
||||
return sensorData;
|
||||
}
|
||||
|
||||
@GetMapping("/sensor")
|
||||
SensorData getSensorData() {
|
||||
return sensorData;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package org.mercury.backend;
|
||||
|
||||
public record SensorData(double temperature, double humidity) {
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user