From db16b8f857eabf2700f2484c6d03fbdd3ba5fbef Mon Sep 17 00:00:00 2001 From: Zohra Khan Date: Sun, 30 Jul 2023 12:27:50 +0530 Subject: [PATCH] - Use constructor injection instead of field injection for better testability and maintainability - Rename 'get' method to 'getById' for clarity - Rename 'put' method to 'update' for clarity - Add more descriptive method names - Changed @PostMapping annotation to @GetMapping and @PutMapping as per Rest principle --- .../context/PostgreSQLHistoryContextController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java index 44edc42c3..7fd8287eb 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java @@ -13,7 +13,12 @@ @RequestMapping(value = "/v2/context/postgresql") public class PostgreSQLHistoryContextController { - @Autowired private PostgreSQLHistoryContextClient contextClient; + private final PostgreSQLHistoryContextClient contextClient; + + @Autowired + public PostgreSQLHistoryContextController(PostgreSQLHistoryContextClient contextClient) { + this.contextClient = contextClient; + } @PostMapping("/create") public Single create( @@ -21,7 +26,7 @@ public Single create( return this.contextClient.create(id, endpoint).toSingle(); } - @PostMapping("/update") + @PutMapping("/update") public Single put( @RequestBody ContextPutRequest request) { return this.contextClient