Skip to content

Commit

Permalink
Add /_version api to the endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Romy <[email protected]>
  • Loading branch information
romayalon committed Feb 12, 2025
1 parent 23aec8d commit 78f2a8f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/endpoint/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require('../util/dotenv').load();
require('../util/panic');
require('../util/fips');
const pkg = require('../../package.json');

const dbg = require('../util/debug_module')(__filename);
if (!dbg.get_process_name()) dbg.set_process_name('Endpoint');
Expand Down Expand Up @@ -294,6 +295,11 @@ function create_endpoint_handler(server_type, init_request_sdk, { virtual_hosts,
return fork_count_handler(req, res);
} else if (req.url.startsWith('/endpoint_fork_id')) {
return endpoint_fork_id_handler(req, res);
} else if (req.url.startsWith('/_')) {
// internals non S3 requests
if (req.url === '/_version') {
return version_handler(req, res);
}
} else {
return s3_rest.handler(req, res);
}
Expand Down Expand Up @@ -349,6 +355,21 @@ function fork_count_handler(req, res) {
res.end(JSON.stringify(reply));
}

/**
* version_handler return the version of noobaa package
* @param {*} req
* @param {*} res
*/
function version_handler(req, res) {
const reply = {
version: pkg.version,
};
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.setHeader('Content-Length', Buffer.byteLength(JSON.stringify(reply)));
res.end(JSON.stringify(reply));
}

/**
* @param {typeof server_rpc.rpc} rpc
* @param {nb.APIClient} internal_rpc_client
Expand Down

0 comments on commit 78f2a8f

Please sign in to comment.