mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
(cherry picked from commit 6824718c0a
)
Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
This commit is contained in:
parent
95e32aaab5
commit
e55eebd128
4 changed files with 17 additions and 4 deletions
|
@ -20,6 +20,7 @@ import {
|
|||
} from '@kbn/core/server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { map$ } from '@kbn/std';
|
||||
import { RouteConfigOptions } from '@kbn/core-http-server';
|
||||
import {
|
||||
StreamingResponseHandler,
|
||||
BatchRequestData,
|
||||
|
@ -54,7 +55,8 @@ export interface BfetchServerSetup {
|
|||
context: RequestHandlerContext
|
||||
) => StreamingResponseHandler<Payload, Response>,
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE',
|
||||
pluginRouter?: ReturnType<CoreSetup['http']['createRouter']>
|
||||
pluginRouter?: ReturnType<CoreSetup['http']['createRouter']>,
|
||||
options?: RouteConfigOptions<'get' | 'post' | 'put' | 'delete'>
|
||||
) => void;
|
||||
}
|
||||
|
||||
|
@ -117,14 +119,16 @@ export class BfetchServerPlugin
|
|||
router: ReturnType<CoreSetup['http']['createRouter']>;
|
||||
logger: Logger;
|
||||
}): BfetchServerSetup['addStreamingResponseRoute'] =>
|
||||
(path, handler, method = 'POST', pluginRouter) => {
|
||||
(path, handler, method = 'POST', pluginRouter, options) => {
|
||||
const httpRouter = pluginRouter || router;
|
||||
|
||||
const routeDefinition = {
|
||||
path: `/${removeLeadingSlash(path)}`,
|
||||
validate: {
|
||||
body: schema.any(),
|
||||
query: schema.object({ compress: schema.boolean({ defaultValue: false }) }),
|
||||
},
|
||||
options,
|
||||
};
|
||||
const routeHandler: RequestHandler<unknown, Query> = async (
|
||||
context: RequestHandlerContext,
|
||||
|
|
|
@ -13,6 +13,8 @@ import { API_URLS } from '../../../common/constants';
|
|||
import { getAllLocations } from '../../synthetics_service/get_all_locations';
|
||||
import { ProjectMonitorFormatter } from '../../synthetics_service/project_monitor/project_monitor_formatter';
|
||||
|
||||
const MAX_PAYLOAD_SIZE = 1048576 * 20; // 20MiB
|
||||
|
||||
export const addSyntheticsProjectMonitorRoute: SyntheticsStreamingRouteFactory = (
|
||||
libs: UMServerLibs
|
||||
) => ({
|
||||
|
@ -25,6 +27,11 @@ export const addSyntheticsProjectMonitorRoute: SyntheticsStreamingRouteFactory =
|
|||
monitors: schema.arrayOf(schema.any()),
|
||||
}),
|
||||
},
|
||||
options: {
|
||||
body: {
|
||||
maxBytes: MAX_PAYLOAD_SIZE,
|
||||
},
|
||||
},
|
||||
handler: async ({
|
||||
request,
|
||||
savedObjectsClient,
|
||||
|
|
|
@ -57,7 +57,7 @@ export const initSyntheticsServer = (
|
|||
});
|
||||
|
||||
syntheticsAppStreamingApiRoutes.forEach((route) => {
|
||||
const { method, streamHandler, path } = syntheticsRouteWrapper(
|
||||
const { method, streamHandler, path, options } = syntheticsRouteWrapper(
|
||||
createSyntheticsRouteWithAuth(libs, route),
|
||||
server,
|
||||
syntheticsMonitorClient
|
||||
|
@ -82,7 +82,8 @@ export const initSyntheticsServer = (
|
|||
};
|
||||
},
|
||||
method,
|
||||
server.router
|
||||
server.router,
|
||||
options
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@ export const syntheticsRouteWrapper: SyntheticsRouteWrapper = (
|
|||
...uptimeRoute,
|
||||
options: {
|
||||
tags: ['access:uptime-read', ...(uptimeRoute?.writeAccess ? ['access:uptime-write'] : [])],
|
||||
...(uptimeRoute.options ?? {}),
|
||||
},
|
||||
streamHandler: async (context, request, subject) => {
|
||||
const coreContext = await context.core;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue