Skip to content

Commit

Permalink
/stations/<stationType> explicit Content-Type to prevent client error…
Browse files Browse the repository at this point in the history
…s after spring upgrade
  • Loading branch information
clezag committed Dec 5, 2023
1 parent b71ed77 commit 34b8a3b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions writer/src/main/java/it/bz/idm/bdp/writer/JsonController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import jakarta.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -91,16 +92,22 @@ public ResponseEntity<Date> dateOfLastRecord(
return ResponseEntity.ok(dataManager.getDateOfLastRecord(stationType, stationId, typeId, period));
}

@GetMapping(value = "/stations/{integreenTypology}")
@GetMapping(value = "/stations/{integreenTypology}", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
// This actually returns a List<StationDto> format wise, but for optimization purposes the whole JSON is built during SQL query already.
public Object stationsGetList(
HttpServletRequest request,
@PathVariable("integreenTypology") String stationType,
@RequestParam(value = "origin", required = false) String origin,
@RequestParam(value = "prn", required = false) String provenanceName,
@RequestParam(value = "prv", required = false) String provenanceVersion
) {
return dataManager.getStationsNative(stationType, origin);
try {
return dataManager.getStationsNative(stationType, origin);
} catch (Throwable t){
t.printStackTrace();
}
return null;
}

@GetMapping(value = "/stations")
Expand Down

0 comments on commit 34b8a3b

Please sign in to comment.