Return 201 status code for successful resources creation
This commit is contained in:
parent
e009fb598c
commit
38356c3a65
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@ -81,7 +82,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startRoomCompositeEgress(roomName, output, "grid")
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating RoomComposite egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -114,7 +116,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startRoomCompositeEgress(roomName, output, "grid")
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating RoomComposite egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -148,7 +151,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startParticipantEgress(roomName, participantIdentity, outputs, false)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating Participant egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -182,7 +186,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startTrackCompositeEgress(roomName, output, audioTrackId, videoTrackId)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating TrackComposite egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -214,7 +219,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startTrackEgress(roomName, output, trackId)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating Track egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -246,7 +252,8 @@ public class EgressController {
|
||||
EgressInfo egress = egressClient.startWebEgress(url, output)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("egress", convertToJson(egress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("egress", convertToJson(egress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating Web egress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -318,7 +325,7 @@ public class EgressController {
|
||||
* @return JSON object with the updated egress
|
||||
*/
|
||||
@PostMapping("/{egressId}/streams")
|
||||
public ResponseEntity<Map<String, Object>> updateEgressStream(@PathVariable String egressId,
|
||||
public ResponseEntity<Map<String, Object>> updateEgressStreams(@PathVariable String egressId,
|
||||
@RequestBody Map<String, Object> params) {
|
||||
Object streamUrlsToAddObj = params.get("streamUrlsToAdd");
|
||||
Object streamUrlsToRemoveObj = params.get("streamUrlsToRemove");
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@ -74,7 +75,8 @@ public class IngressController {
|
||||
.createIngress("rtmp-ingress", roomName, participantIdentity, null, IngressInput.RTMP_INPUT)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("ingress", convertToJson(ingress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("ingress", convertToJson(ingress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating RTMP ingress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -104,7 +106,8 @@ public class IngressController {
|
||||
.createIngress("whip-ingress", roomName, participantIdentity, null, IngressInput.WHIP_INPUT)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("ingress", convertToJson(ingress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("ingress", convertToJson(ingress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating WHIP ingress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -136,7 +139,8 @@ public class IngressController {
|
||||
null, null, null, url)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("ingress", convertToJson(ingress)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("ingress", convertToJson(ingress)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating URL ingress";
|
||||
LOGGER.error(errorMessage, e);
|
||||
@ -187,8 +191,10 @@ public class IngressController {
|
||||
}
|
||||
|
||||
try {
|
||||
// Know bug: participantIdentity must be provided in order to not fail, but it is not used
|
||||
IngressInfo ingress = ingressClient.updateIngress(ingressId, "updated-ingress", roomName, "Ingress-Participant")
|
||||
// Know bug: participantIdentity must be provided in order to not fail,
|
||||
// but it is not used
|
||||
IngressInfo ingress = ingressClient
|
||||
.updateIngress(ingressId, "updated-ingress", roomName, "Ingress-Participant")
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("ingress", convertToJson(ingress)));
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@ -77,7 +78,8 @@ public class RoomController {
|
||||
Room room = roomClient.createRoom(roomName)
|
||||
.execute()
|
||||
.body();
|
||||
return ResponseEntity.ok(Map.of("room", convertToJson(room)));
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(Map.of("room", convertToJson(room)));
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "Error creating room";
|
||||
LOGGER.error(errorMessage, e);
|
||||
|
||||
@ -33,7 +33,7 @@ egressController.post("/room-composite", async (req, res) => {
|
||||
layout: "grid"
|
||||
};
|
||||
const egress = await egressClient.startRoomCompositeEgress(roomName, outputs, options);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating RoomComposite egress";
|
||||
console.error(errorMessage, error);
|
||||
@ -58,7 +58,7 @@ egressController.post("/stream", async (req, res) => {
|
||||
})
|
||||
};
|
||||
const egress = await egressClient.startRoomCompositeEgress(roomName, outputs);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating RoomComposite egress";
|
||||
console.error(errorMessage, error);
|
||||
@ -86,7 +86,7 @@ egressController.post("/participant", async (req, res) => {
|
||||
screenShare: false
|
||||
};
|
||||
const egress = await egressClient.startParticipantEgress(roomName, participantIdentity, outputs, options);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating Participant egress";
|
||||
console.error(errorMessage, error);
|
||||
@ -115,7 +115,7 @@ egressController.post("/track-composite", async (req, res) => {
|
||||
audioTrackId
|
||||
};
|
||||
const egress = await egressClient.startTrackCompositeEgress(roomName, outputs, options);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating TrackComposite egress";
|
||||
console.error(errorMessage, error);
|
||||
@ -137,7 +137,7 @@ egressController.post("/track", async (req, res) => {
|
||||
filepath: "{room_name}-{room_id}-{publisher_identity}-{track_source}-{track_id}-{time}"
|
||||
});
|
||||
const egress = await egressClient.startTrackEgress(roomName, output, trackId);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating Track egress";
|
||||
console.error(errorMessage, error);
|
||||
@ -162,7 +162,7 @@ egressController.post("/web", async (req, res) => {
|
||||
})
|
||||
};
|
||||
const egress = await egressClient.startWebEgress(url, outputs);
|
||||
res.json({ egress });
|
||||
res.status(201).json({ egress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating Web egress";
|
||||
console.error(errorMessage, error);
|
||||
|
||||
@ -22,7 +22,7 @@ ingressController.post("/rtmp", async (req, res) => {
|
||||
participantIdentity
|
||||
};
|
||||
const ingress = await ingressClient.createIngress(IngressInput.RTMP_INPUT, ingressOptions);
|
||||
res.json({ ingress });
|
||||
res.status(201).json({ ingress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating RTMP ingress";
|
||||
console.error(errorMessage, error);
|
||||
@ -46,7 +46,7 @@ ingressController.post("/whip", async (req, res) => {
|
||||
participantIdentity
|
||||
};
|
||||
const ingress = await ingressClient.createIngress(IngressInput.WHIP_INPUT, ingressOptions);
|
||||
res.json({ ingress });
|
||||
res.status(201).json({ ingress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating WHIP ingress";
|
||||
console.error(errorMessage, error);
|
||||
@ -71,7 +71,7 @@ ingressController.post("/url", async (req, res) => {
|
||||
url
|
||||
};
|
||||
const ingress = await ingressClient.createIngress(IngressInput.URL_INPUT, ingressOptions);
|
||||
res.json({ ingress });
|
||||
res.status(201).json({ ingress });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating URL ingress";
|
||||
console.error(errorMessage, error);
|
||||
|
||||
@ -20,7 +20,7 @@ roomController.post("/", async (req, res) => {
|
||||
name: roomName
|
||||
};
|
||||
const room = await roomClient.createRoom(roomOptions);
|
||||
res.json({ room });
|
||||
res.status(201).json({ room });
|
||||
} catch (error) {
|
||||
const errorMessage = "Error creating room";
|
||||
console.error(errorMessage, error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user