diff --git a/docs/API.md b/docs/API.md index 89a054bf9..fa68702d5 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1128,7 +1128,7 @@ returns the current indexing queue, as an array of objects ## PolicyServer Passthrough -### `HTTP` POST /PolicyServerPassthrough +### `HTTP` POST /api/services/PolicyServerPassthrough ### `P2P` command: PolicyServerPassthrough diff --git a/src/components/httpRoutes/index.ts b/src/components/httpRoutes/index.ts index ee974a52d..9b302f395 100644 --- a/src/components/httpRoutes/index.ts +++ b/src/components/httpRoutes/index.ts @@ -12,6 +12,7 @@ import { queueRoutes } from './queue.js' // import { getConfiguration } from '../../utils/config.js' import { jobsRoutes } from './jobs.js' import { addMapping, allRoutesMapping, findPathName } from './routeUtils.js' +import { PolicyServerPassthroughRoute } from './policyServer.js' export * from './getOceanPeers.js' @@ -57,7 +58,8 @@ httpRoutes.use(computeRoutes) httpRoutes.use(queueRoutes) // running jobs httpRoutes.use(jobsRoutes) - +// policy server passthrough +httpRoutes.use(PolicyServerPassthroughRoute) export function getAllServiceEndpoints() { httpRoutes.stack.forEach(addMapping.bind(null, [])) const data: any = {} diff --git a/src/components/httpRoutes/routeUtils.ts b/src/components/httpRoutes/routeUtils.ts index 4843f5d0e..2ec92a9f1 100644 --- a/src/components/httpRoutes/routeUtils.ts +++ b/src/components/httpRoutes/routeUtils.ts @@ -174,6 +174,11 @@ routesNames.set('indexQueue', { method: 'get' }) +routesNames.set('PolicyServerPassthrough', { + path: `${SERVICES_API_BASE_PATH}/PolicyServerPassthrough`, + method: 'post' +}) + export function addMapping(path: any, layer: any) { if (layer.route) { layer.route.stack.forEach(addMapping.bind(null, path.concat(split(layer.route.path)))) diff --git a/src/components/policyServer/index.ts b/src/components/policyServer/index.ts index eeb0523c1..ddc33f5a2 100644 --- a/src/components/policyServer/index.ts +++ b/src/components/policyServer/index.ts @@ -24,7 +24,11 @@ export class PolicyServer { return { success: true, message: '', httpStatus: 0 } } if (response.status === 200) { - return { success: true, message: '', httpStatus: response.status } + return { + success: true, + message: await response.text(), + httpStatus: response.status + } } return { success: false, message: await response.text(), httpStatus: response.status } }