1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

api: check version

This commit is contained in:
Steffen Vogel 2018-11-02 15:00:03 +01:00
parent 5370bb5a73
commit 9bda0fdfd5
3 changed files with 9 additions and 2 deletions

View file

@ -39,6 +39,8 @@ namespace villas {
namespace node {
namespace api {
const int version = 1;
/* Forward declarations */
class Session;

View file

@ -24,11 +24,13 @@
#include <libwebsockets.h>
#include <villas/exceptions.hpp>
#include <villas/web.hpp>
#include <villas/log.hpp>
#include <villas/config.h>
#include <villas/api/sessions/http.hpp>
using namespace villas;
using namespace villas::node;
using namespace villas::node::api::sessions;
@ -49,7 +51,8 @@ Http::Http(Api *a, lws *w) :
/* Parse request URI */
sscanf(uri, "/api/v%d", (int *) &version);
/** @todo Check version */
if (version != api::version)
throw RuntimeError("Unsupported API version: {}", version);
/* This is an OPTIONS request.
*

View file

@ -25,6 +25,7 @@
#include <libwebsockets.h>
#include <villas/web.hpp>
#include <villas/exceptions.hpp>
#include <villas/log.hpp>
#include <villas/api/sessions/websocket.hpp>
@ -41,7 +42,8 @@ WebSocket::WebSocket(Api *a, lws *w) :
sscanf(uri, "/v%d", (int *) &version);
/** @todo Check version */
if (version != api::version)
throw RuntimeError("Unsupported API version: {}", version);
}
WebSocket::~WebSocket()