mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
task: Add an X-Unleash-Version header to register response (#5774)
Related to our work for making Edge bulk metrics a 1st class citizen of Unleash, this PR adds an X-Unleash-Version header to the response from client registration. Based on when we add the new `/api/client/metrics/bulk` endpoint, Edge can use the response header from upstream to decide whether to post metrics to `/edge/metrics` or `/api/client/metrics/bulk`.
This commit is contained in:
parent
04814bfc63
commit
e769ceab05
@ -102,3 +102,19 @@ test('should allow an empty instanceId field', () => {
|
|||||||
})
|
})
|
||||||
.expect(202);
|
.expect(202);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Includes an X-Unleash-Version header in the response', () => {
|
||||||
|
return request
|
||||||
|
.post('/api/client/register')
|
||||||
|
.send({
|
||||||
|
appName: 'demo',
|
||||||
|
instanceId: '',
|
||||||
|
strategies: ['default'],
|
||||||
|
started: Date.now(),
|
||||||
|
interval: 10,
|
||||||
|
})
|
||||||
|
.expect(202)
|
||||||
|
.expect((res) => {
|
||||||
|
expect(res.headers['x-unleash-version']).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -15,6 +15,7 @@ import { createRequestSchema } from '../../openapi/util/create-request-schema';
|
|||||||
import { ClientApplicationSchema } from '../../openapi/spec/client-application-schema';
|
import { ClientApplicationSchema } from '../../openapi/spec/client-application-schema';
|
||||||
import rateLimit from 'express-rate-limit';
|
import rateLimit from 'express-rate-limit';
|
||||||
import { minutesToMilliseconds } from 'date-fns';
|
import { minutesToMilliseconds } from 'date-fns';
|
||||||
|
import version from '../../util/version';
|
||||||
|
|
||||||
export default class RegisterController extends Controller {
|
export default class RegisterController extends Controller {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
@ -93,6 +94,6 @@ export default class RegisterController extends Controller {
|
|||||||
data.environment = RegisterController.resolveEnvironment(user, data);
|
data.environment = RegisterController.resolveEnvironment(user, data);
|
||||||
data.project = RegisterController.extractProjectFromRequest(req);
|
data.project = RegisterController.extractProjectFromRequest(req);
|
||||||
await this.clientInstanceService.registerClient(data, clientIp);
|
await this.clientInstanceService.registerClient(data, clientIp);
|
||||||
res.status(202).end();
|
res.header('X-Unleash-Version', version).status(202).end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user