Skip to content

Commit

Permalink
refactor: rtp endpoint
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Garczorz <[email protected]>
  • Loading branch information
towi and insomnick committed Nov 14, 2024
1 parent f65d6b8 commit 8a19f09
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand Down Expand Up @@ -102,8 +104,8 @@ public ResponseEntity<List<String>> getAllX3() throws IOException {

// ================================

@GetMapping(value = "/all/rtp/{xid}", produces = "application/octet-stream")
public ResponseEntity<byte[]> getAllRtp(@PathVariable final UUID xid) throws IOException {
@GetMapping(value = "/all/rtp/{xid}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody byte[] getAllRtp(@PathVariable final UUID xid) throws IOException {
try (final var buf = new ByteArrayOutputStream()) {
x2X3Memory
.getStorage()
Expand All @@ -113,7 +115,7 @@ public ResponseEntity<byte[]> getAllRtp(@PathVariable final UUID xid) throws IOE
.sorted(Comparator.comparingInt(pdu -> pdu.findSequenceNumber().orElse(-1)))
.map(PduObject::payload)
.forEach(payload -> writeToBuf(payload, buf));
return ResponseEntity.ok(buf.toByteArray());
return buf.toByteArray();
}
}

Expand Down

0 comments on commit 8a19f09

Please sign in to comment.