Files
harbor-net/src/server/http/routes/routeRulesRoute.ts
T
dokril 7c255192b0
Build and Deploy Gateway / build-and-push (push) Successful in 35s
Build and Deploy Gateway / deploy (push) Successful in 14s
Update Harbor client and gateway functionality
2026-08-17 15:23:16 +03:00

22 lines
882 B
TypeScript

import type { IncomingMessage, ServerResponse } from 'node:http';
import type { RouteRulesService } from '../../features/routing/index.js';
interface RouteRulesRouteDependencies {
routeRules: RouteRulesService;
readBody(req: IncomingMessage): Promise<Record<string, unknown>>;
sendState(res: ServerResponse): Promise<void>;
}
export function createRouteRulesRoute(dependencies: RouteRulesRouteDependencies) {
return {
async handle(req: IncomingMessage, res: ServerResponse) {
if (req.method !== 'PUT' || !['/api/route-rules', '/api/route-rules/v2'].includes(req.url || '')) return false;
const { rules, expectedRulesRevision, rulesContractVersion } = await dependencies.readBody(req);
await dependencies.routeRules.update(rules, expectedRulesRevision, rulesContractVersion);
await dependencies.sendState(res);
return true;
},
};
}