mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* add HttpResources basic implementation * expose http resources to plugins * add mocks * move http resources to a separate service * hide rendering service * adopt internal types * expose HttpResources service to plugins * update platform mocks * plugins start using HttpResources API * remove RenderingServiceSetup export * RenderingServiceSetup --> InternalRenderingServiceSetup * improve types * remove httpRespources leftovers from http service * remove rendering types from RequestHanlderContext * fix security plugin tests * add unit tests for httpResources service * add unit tests * remove outdated cache-control header * restructure http resources service * merge getUiPlugins and discover * static route declaration shouldnt require auth & validate * update docs * use HttpResources service instad of rendering * address comments * update docs * roll back unnecessary changes * use getVars for rendering * dont pass app. it is not public API * remove static registers * update migration guide
This commit is contained in:
parent
0f04d2a38d
commit
a2ceb6591d
78 changed files with 1485 additions and 522 deletions
|
@ -9,5 +9,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
http: HttpServiceSetup;
|
||||
http: HttpServiceSetup & {
|
||||
resources: HttpResources;
|
||||
};
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
|
|||
| [context](./kibana-plugin-core-server.coresetup.context.md) | <code>ContextSetup</code> | [ContextSetup](./kibana-plugin-core-server.contextsetup.md) |
|
||||
| [elasticsearch](./kibana-plugin-core-server.coresetup.elasticsearch.md) | <code>ElasticsearchServiceSetup</code> | [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) |
|
||||
| [getStartServices](./kibana-plugin-core-server.coresetup.getstartservices.md) | <code>StartServicesAccessor<TPluginsStart, TStart></code> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) |
|
||||
| [http](./kibana-plugin-core-server.coresetup.http.md) | <code>HttpServiceSetup</code> | [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) |
|
||||
| [http](./kibana-plugin-core-server.coresetup.http.md) | <code>HttpServiceSetup & {</code><br/><code> resources: HttpResources;</code><br/><code> }</code> | [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) |
|
||||
| [metrics](./kibana-plugin-core-server.coresetup.metrics.md) | <code>MetricsServiceSetup</code> | [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) |
|
||||
| [savedObjects](./kibana-plugin-core-server.coresetup.savedobjects.md) | <code>SavedObjectsServiceSetup</code> | [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) |
|
||||
| [status](./kibana-plugin-core-server.coresetup.status.md) | <code>StatusServiceSetup</code> | [StatusServiceSetup](./kibana-plugin-core-server.statusservicesetup.md) |
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResources](./kibana-plugin-core-server.httpresources.md)
|
||||
|
||||
## HttpResources interface
|
||||
|
||||
HttpResources service is responsible for serving static & dynamic assets for Kibana application via HTTP. Provides API allowing plug-ins to respond with: - a pre-configured HTML page bootstrapping Kibana client app - custom HTML page - custom JS script file.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface HttpResources
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [register](./kibana-plugin-core-server.httpresources.register.md) | <code><P, Q, B>(route: RouteConfig<P, Q, B, 'get'>, handler: HttpResourcesRequestHandler<P, Q, B>) => void</code> | To register a route handler executing passed function to form response. |
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResources](./kibana-plugin-core-server.httpresources.md) > [register](./kibana-plugin-core-server.httpresources.register.md)
|
||||
|
||||
## HttpResources.register property
|
||||
|
||||
To register a route handler executing passed function to form response.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
register: <P, Q, B>(route: RouteConfig<P, Q, B, 'get'>, handler: HttpResourcesRequestHandler<P, Q, B>) => void;
|
||||
```
|
|
@ -0,0 +1,18 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesRenderOptions](./kibana-plugin-core-server.httpresourcesrenderoptions.md) > [headers](./kibana-plugin-core-server.httpresourcesrenderoptions.headers.md)
|
||||
|
||||
## HttpResourcesRenderOptions.headers property
|
||||
|
||||
HTTP Headers with additional information about response.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
headers?: ResponseHeaders;
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
All HTML pages are already pre-configured with `content-security-policy` header that cannot be overridden.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesRenderOptions](./kibana-plugin-core-server.httpresourcesrenderoptions.md)
|
||||
|
||||
## HttpResourcesRenderOptions interface
|
||||
|
||||
Allows to configure HTTP response parameters
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface HttpResourcesRenderOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [headers](./kibana-plugin-core-server.httpresourcesrenderoptions.headers.md) | <code>ResponseHeaders</code> | HTTP Headers with additional information about response. |
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesRequestHandler](./kibana-plugin-core-server.httpresourcesrequesthandler.md)
|
||||
|
||||
## HttpResourcesRequestHandler type
|
||||
|
||||
Extended version of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) having access to [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) to respond with HTML or JS resources.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type HttpResourcesRequestHandler<P = unknown, Q = unknown, B = unknown> = RequestHandler<P, Q, B, 'get', KibanaResponseFactory & HttpResourcesServiceToolkit>;
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
\`\`\`<!-- -->typescript httpResources.register(<!-- -->{ path: '/login', validate: { params: schema.object(<!-- -->{ id: schema.string() }<!-- -->), }<!-- -->, }<!-- -->, async (context, request, response) =<!-- -->> { //.. return response.renderCoreApp(); }<!-- -->);
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesResponseOptions](./kibana-plugin-core-server.httpresourcesresponseoptions.md)
|
||||
|
||||
## HttpResourcesResponseOptions type
|
||||
|
||||
HTTP Resources response parameters
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type HttpResourcesResponseOptions = HttpResponseOptions;
|
||||
```
|
|
@ -0,0 +1,23 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md)
|
||||
|
||||
## HttpResourcesServiceToolkit interface
|
||||
|
||||
Extended set of [KibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) helpers used to respond with HTML or JS resource.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface HttpResourcesServiceToolkit
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [renderAnonymousCoreApp](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderanonymouscoreapp.md) | <code>(options?: HttpResourcesRenderOptions) => Promise<IKibanaResponse></code> | To respond with HTML page bootstrapping Kibana application without retrieving user-specific information. |
|
||||
| [renderCoreApp](./kibana-plugin-core-server.httpresourcesservicetoolkit.rendercoreapp.md) | <code>(options?: HttpResourcesRenderOptions) => Promise<IKibanaResponse></code> | To respond with HTML page bootstrapping Kibana application. |
|
||||
| [renderHtml](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderhtml.md) | <code>(options: HttpResourcesResponseOptions) => IKibanaResponse</code> | To respond with a custom HTML page. |
|
||||
| [renderJs](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderjs.md) | <code>(options: HttpResourcesResponseOptions) => IKibanaResponse</code> | To respond with a custom JS script file. |
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) > [renderAnonymousCoreApp](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderanonymouscoreapp.md)
|
||||
|
||||
## HttpResourcesServiceToolkit.renderAnonymousCoreApp property
|
||||
|
||||
To respond with HTML page bootstrapping Kibana application without retrieving user-specific information.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
renderAnonymousCoreApp: (options?: HttpResourcesRenderOptions) => Promise<IKibanaResponse>;
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) > [renderCoreApp](./kibana-plugin-core-server.httpresourcesservicetoolkit.rendercoreapp.md)
|
||||
|
||||
## HttpResourcesServiceToolkit.renderCoreApp property
|
||||
|
||||
To respond with HTML page bootstrapping Kibana application.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
renderCoreApp: (options?: HttpResourcesRenderOptions) => Promise<IKibanaResponse>;
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) > [renderHtml](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderhtml.md)
|
||||
|
||||
## HttpResourcesServiceToolkit.renderHtml property
|
||||
|
||||
To respond with a custom HTML page.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
renderHtml: (options: HttpResourcesResponseOptions) => IKibanaResponse;
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) > [renderJs](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderjs.md)
|
||||
|
||||
## HttpResourcesServiceToolkit.renderJs property
|
||||
|
||||
To respond with a custom JS script file.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
renderJs: (options: HttpResourcesResponseOptions) => IKibanaResponse;
|
||||
```
|
|
@ -9,5 +9,5 @@ Wrap a router handler to catch and converts legacy boom errors to proper custom
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
handleLegacyErrors: <P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B>;
|
||||
handleLegacyErrors: RequestHandlerWrapper;
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ export interface IRouter
|
|||
| --- | --- | --- |
|
||||
| [delete](./kibana-plugin-core-server.irouter.delete.md) | <code>RouteRegistrar<'delete'></code> | Register a route handler for <code>DELETE</code> request. |
|
||||
| [get](./kibana-plugin-core-server.irouter.get.md) | <code>RouteRegistrar<'get'></code> | Register a route handler for <code>GET</code> request. |
|
||||
| [handleLegacyErrors](./kibana-plugin-core-server.irouter.handlelegacyerrors.md) | <code><P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B></code> | Wrap a router handler to catch and converts legacy boom errors to proper custom errors. |
|
||||
| [handleLegacyErrors](./kibana-plugin-core-server.irouter.handlelegacyerrors.md) | <code>RequestHandlerWrapper</code> | Wrap a router handler to catch and converts legacy boom errors to proper custom errors. |
|
||||
| [patch](./kibana-plugin-core-server.irouter.patch.md) | <code>RouteRegistrar<'patch'></code> | Register a route handler for <code>PATCH</code> request. |
|
||||
| [post](./kibana-plugin-core-server.irouter.post.md) | <code>RouteRegistrar<'post'></code> | Register a route handler for <code>POST</code> request. |
|
||||
| [put](./kibana-plugin-core-server.irouter.put.md) | <code>RouteRegistrar<'put'></code> | Register a route handler for <code>PUT</code> request. |
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [IScopedRenderingClient](./kibana-plugin-core-server.iscopedrenderingclient.md)
|
||||
|
||||
## IScopedRenderingClient interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface IScopedRenderingClient
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| [render(options)](./kibana-plugin-core-server.iscopedrenderingclient.render.md) | Generate a <code>KibanaResponse</code> which renders an HTML page bootstrapped with the <code>core</code> bundle. Intended as a response body for HTTP route handlers. |
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [IScopedRenderingClient](./kibana-plugin-core-server.iscopedrenderingclient.md) > [render](./kibana-plugin-core-server.iscopedrenderingclient.render.md)
|
||||
|
||||
## IScopedRenderingClient.render() method
|
||||
|
||||
Generate a `KibanaResponse` which renders an HTML page bootstrapped with the `core` bundle. Intended as a response body for HTTP route handlers.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
render(options?: Pick<IRenderOptions, 'includeUserSettings'>): Promise<string>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| options | <code>Pick<IRenderOptions, 'includeUserSettings'></code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Promise<string>`
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
```ts
|
||||
router.get(
|
||||
{ path: '/', validate: false },
|
||||
(context, request, response) =>
|
||||
response.ok({
|
||||
body: await context.core.rendering.render(),
|
||||
headers: {
|
||||
'content-security-policy': context.core.http.csp.header,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
```
|
||||
|
|
@ -20,4 +20,5 @@ export interface LegacyServiceSetupDeps
|
|||
| --- | --- | --- |
|
||||
| [core](./kibana-plugin-core-server.legacyservicesetupdeps.core.md) | <code>LegacyCoreSetup</code> | |
|
||||
| [plugins](./kibana-plugin-core-server.legacyservicesetupdeps.plugins.md) | <code>Record<string, unknown></code> | |
|
||||
| [uiPlugins](./kibana-plugin-core-server.legacyservicesetupdeps.uiplugins.md) | <code>UiPlugins</code> | |
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [LegacyServiceSetupDeps](./kibana-plugin-core-server.legacyservicesetupdeps.md) > [uiPlugins](./kibana-plugin-core-server.legacyservicesetupdeps.uiplugins.md)
|
||||
|
||||
## LegacyServiceSetupDeps.uiPlugins property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
uiPlugins: UiPlugins;
|
||||
```
|
|
@ -80,6 +80,9 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) | |
|
||||
| [ErrorHttpResponseOptions](./kibana-plugin-core-server.errorhttpresponseoptions.md) | HTTP response parameters |
|
||||
| [FakeRequest](./kibana-plugin-core-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
|
||||
| [HttpResources](./kibana-plugin-core-server.httpresources.md) | HttpResources service is responsible for serving static & dynamic assets for Kibana application via HTTP. Provides API allowing plug-ins to respond with: - a pre-configured HTML page bootstrapping Kibana client app - custom HTML page - custom JS script file. |
|
||||
| [HttpResourcesRenderOptions](./kibana-plugin-core-server.httpresourcesrenderoptions.md) | Allows to configure HTTP response parameters |
|
||||
| [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) | Extended set of [KibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) helpers used to respond with HTML or JS resource. |
|
||||
| [HttpResponseOptions](./kibana-plugin-core-server.httpresponseoptions.md) | HTTP response parameters |
|
||||
| [HttpServerInfo](./kibana-plugin-core-server.httpserverinfo.md) | |
|
||||
| [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to <code>hapi</code> server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
|
||||
|
@ -92,7 +95,6 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [IndexSettingsDeprecationInfo](./kibana-plugin-core-server.indexsettingsdeprecationinfo.md) | |
|
||||
| [IRenderOptions](./kibana-plugin-core-server.irenderoptions.md) | |
|
||||
| [IRouter](./kibana-plugin-core-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-core-server.routeconfig.md) and [RequestHandler](./kibana-plugin-core-server.requesthandler.md) for more information about arguments to route registrations. |
|
||||
| [IScopedRenderingClient](./kibana-plugin-core-server.iscopedrenderingclient.md) | |
|
||||
| [IUiSettingsClient](./kibana-plugin-core-server.iuisettingsclient.md) | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
|
||||
| [KibanaRequestEvents](./kibana-plugin-core-server.kibanarequestevents.md) | Request events. |
|
||||
| [KibanaRequestRoute](./kibana-plugin-core-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
|
||||
|
@ -118,7 +120,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [PluginConfigDescriptor](./kibana-plugin-core-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
|
||||
| [PluginInitializerContext](./kibana-plugin-core-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
|
||||
| [PluginManifest](./kibana-plugin-core-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
|
||||
| [RequestHandlerContext](./kibana-plugin-core-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients and services: - [rendering](./kibana-plugin-core-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.dataClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
|
||||
| [RequestHandlerContext](./kibana-plugin-core-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.dataClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
|
||||
| [RouteConfig](./kibana-plugin-core-server.routeconfig.md) | Route specific configuration. |
|
||||
| [RouteConfigOptions](./kibana-plugin-core-server.routeconfigoptions.md) | Additional route options. |
|
||||
| [RouteConfigOptionsBody](./kibana-plugin-core-server.routeconfigoptionsbody.md) | Additional body options for a route |
|
||||
|
@ -216,6 +218,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [HandlerFunction](./kibana-plugin-core-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-core-server.icontextcontainer.md) |
|
||||
| [HandlerParameters](./kibana-plugin-core-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-core-server.handlerfunction.md)<!-- -->, excluding the [HandlerContextType](./kibana-plugin-core-server.handlercontexttype.md)<!-- -->. |
|
||||
| [Headers](./kibana-plugin-core-server.headers.md) | Http request headers to read. |
|
||||
| [HttpResourcesRequestHandler](./kibana-plugin-core-server.httpresourcesrequesthandler.md) | Extended version of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) having access to [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) to respond with HTML or JS resources. |
|
||||
| [HttpResourcesResponseOptions](./kibana-plugin-core-server.httpresourcesresponseoptions.md) | HTTP Resources response parameters |
|
||||
| [HttpResponsePayload](./kibana-plugin-core-server.httpresponsepayload.md) | Data send to the client as a response payload. |
|
||||
| [IBasePath](./kibana-plugin-core-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-core-server.basepath.md) |
|
||||
| [IClusterClient](./kibana-plugin-core-server.iclusterclient.md) | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-core-server.clusterclient.md)<!-- -->. |
|
||||
|
@ -245,6 +249,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [RequestHandler](./kibana-plugin-core-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) functions. |
|
||||
| [RequestHandlerContextContainer](./kibana-plugin-core-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
|
||||
| [RequestHandlerContextProvider](./kibana-plugin-core-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
|
||||
| [RequestHandlerWrapper](./kibana-plugin-core-server.requesthandlerwrapper.md) | Type-safe wrapper for [RequestHandler](./kibana-plugin-core-server.requesthandler.md) function. |
|
||||
| [ResponseError](./kibana-plugin-core-server.responseerror.md) | Error message and optional data send to the client in case of error. |
|
||||
| [ResponseErrorAttributes](./kibana-plugin-core-server.responseerrorattributes.md) | Additional data to provide error details. |
|
||||
| [ResponseHeaders](./kibana-plugin-core-server.responseheaders.md) | Http response headers to set. |
|
||||
|
|
|
@ -9,7 +9,7 @@ A function executed when route path matched requested resource path. Request han
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type RequestHandler<P = unknown, Q = unknown, B = unknown, Method extends RouteMethod = any> = (context: RequestHandlerContext, request: KibanaRequest<P, Q, B, Method>, response: KibanaResponseFactory) => IKibanaResponse<any> | Promise<IKibanaResponse<any>>;
|
||||
export declare type RequestHandler<P = unknown, Q = unknown, B = unknown, Method extends RouteMethod = any, ResponseFactory extends KibanaResponseFactory = KibanaResponseFactory> = (context: RequestHandlerContext, request: KibanaRequest<P, Q, B, Method>, response: ResponseFactory) => IKibanaResponse<any> | Promise<IKibanaResponse<any>>;
|
||||
```
|
||||
|
||||
## Example
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
```typescript
|
||||
core: {
|
||||
rendering: IScopedRenderingClient;
|
||||
savedObjects: {
|
||||
client: SavedObjectsClientContract;
|
||||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
Plugin specific context passed to a route handler.
|
||||
|
||||
Provides the following clients and services: - [rendering](./kibana-plugin-core-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.dataClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request
|
||||
Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.dataClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
|
@ -18,5 +18,5 @@ export interface RequestHandlerContext
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | <code>{</code><br/><code> rendering: IScopedRenderingClient;</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> typeRegistry: ISavedObjectTypeRegistry;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> dataClient: IScopedClusterClient;</code><br/><code> adminClient: IScopedClusterClient;</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |
|
||||
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | <code>{</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> typeRegistry: ISavedObjectTypeRegistry;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> dataClient: IScopedClusterClient;</code><br/><code> adminClient: IScopedClusterClient;</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [RequestHandlerWrapper](./kibana-plugin-core-server.requesthandlerwrapper.md)
|
||||
|
||||
## RequestHandlerWrapper type
|
||||
|
||||
Type-safe wrapper for [RequestHandler](./kibana-plugin-core-server.requesthandler.md) function.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type RequestHandlerWrapper = <P, Q, B, Method extends RouteMethod = any, ResponseFactory extends KibanaResponseFactory = KibanaResponseFactory>(handler: RequestHandler<P, Q, B, Method, ResponseFactory>) => RequestHandler<P, Q, B, Method, ResponseFactory>;
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
```typescript
|
||||
export const wrapper: RequestHandlerWrapper = handler => {
|
||||
return async (context, request, response) => {
|
||||
// do some logic
|
||||
...
|
||||
};
|
||||
}
|
||||
|
||||
```
|
||||
|
|
@ -9,9 +9,5 @@ Http response headers to set.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type ResponseHeaders = {
|
||||
[header in KnownHeaders]?: string | string[];
|
||||
} & {
|
||||
[header: string]: string | string[];
|
||||
};
|
||||
export declare type ResponseHeaders = Record<KnownHeaders, string | string[]> | Record<string, string | string[]>;
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue