Skip to content

Commit 53957b5

Browse files
authored
Merge pull request #84 from Eyevinn/get-session-vmap-xml
Get session vmap xml through new endpoint
2 parents 878d75b + 5fe486f commit 53957b5

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

api/routes.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,24 @@ const schemas = {
523523
404: BadRequestSchema("Session with ID: 'xxx-xxx-xxx-xxx' was not found"),
524524
},
525525
},
526+
"GET/sessions/:sessionId/vmap": {
527+
description: "Gets the VMAP XML created for a specific session",
528+
tags: ["sessions"],
529+
params: {
530+
sessionId: {
531+
type: "string",
532+
description: "The ID for the session. ",
533+
},
534+
},
535+
response: {
536+
200: {
537+
description: "VMAP XML",
538+
type: "string",
539+
},
540+
541+
404: BadRequestSchema("Session with ID: 'xxx-xxx-xxx-xxx' was not found"),
542+
},
543+
},
526544
"DELETE/sessions/:sessionId": {
527545
description: "Deletes the given session",
528546
tags: ["sessions"],
@@ -969,6 +987,38 @@ module.exports = (fastify, opt, next) => {
969987
}
970988
);
971989

990+
fastify.get(
991+
"/sessions/:sessionId/vmap",
992+
{
993+
schema: schemas["GET/sessions/:sessionId/vmap"],
994+
},
995+
async (req, reply) => {
996+
const sessionId = req.params.sessionId;
997+
try {
998+
// Check if session exists.
999+
const session = await DBAdapter.getSession(sessionId);
1000+
if (!session) {
1001+
reply.code(404).send({
1002+
message: `Session with ID: '${sessionId}' was not found`,
1003+
});
1004+
} else {
1005+
vmap_xml = session.getVmapXml();
1006+
reply.headers({
1007+
"Content-Type": "application/xml;charset=UTF-8",
1008+
});
1009+
reply.code(200).send(vmap_xml);
1010+
}
1011+
} catch (exc) {
1012+
console.error(exc);
1013+
logger.error(exc, {
1014+
label: req.headers["host"],
1015+
sessionId: sessionId,
1016+
});
1017+
reply.code(500).send({ message: exc.message });
1018+
}
1019+
}
1020+
);
1021+
9721022
// Users - routes
9731023
fastify.get(
9741024
"/users/:userId",

0 commit comments

Comments
 (0)