feat(backend): add basic sensor endpoints

This commit is contained in:
Halit Aksoy 2025-01-19 13:10:56 +03:00
parent 5d1d650a70
commit 7e424fe05f
2 changed files with 20 additions and 0 deletions

View File

@ -3,11 +3,16 @@ package org.mercury.backend;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping; 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; import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication @SpringBootApplication
@RestController @RestController
public class BackendApplication { public class BackendApplication {
private SensorData sensorData;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args); SpringApplication.run(BackendApplication.class, args);
} }
@ -16,4 +21,15 @@ public class BackendApplication {
public String hello() { public String hello() {
return String.format("Server up and running!"); 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;
}
} }

View File

@ -0,0 +1,4 @@
package org.mercury.backend;
public record SensorData(double temperature, double humidity) {
}