Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NP] add http resources sub-service #61797

Merged
merged 36 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
601ee0f
add HttpResources basic implementation
mshustov Mar 30, 2020
543ef00
expose http resources to plugins
mshustov Mar 30, 2020
03f4219
add mocks
mshustov Mar 30, 2020
b514e7b
move http resources to a separate service
mshustov Apr 1, 2020
9e34b0e
hide rendering service
mshustov Apr 1, 2020
4c276bf
adopt internal types
mshustov Apr 1, 2020
8a1e10f
expose HttpResources service to plugins
mshustov Apr 1, 2020
1b4ef8e
update platform mocks
mshustov Apr 1, 2020
18309fc
plugins start using HttpResources API
mshustov Apr 1, 2020
5e3d085
remove RenderingServiceSetup export
mshustov Apr 1, 2020
5fc5beb
RenderingServiceSetup --> InternalRenderingServiceSetup
mshustov Apr 1, 2020
6ca04a0
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 1, 2020
b96f741
improve types
mshustov Apr 1, 2020
900d40e
remove httpRespources leftovers from http service
mshustov Apr 1, 2020
4700564
remove rendering types from RequestHanlderContext
mshustov Apr 1, 2020
4daa02c
fix security plugin tests
mshustov Apr 1, 2020
b9f3099
add unit tests for httpResources service
mshustov Apr 1, 2020
cebf397
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 6, 2020
d988c76
add unit tests
mshustov Apr 7, 2020
8150a9e
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 8, 2020
7326679
remove outdated cache-control header
mshustov Apr 8, 2020
6e8ce80
restructure http resources service
mshustov Apr 8, 2020
457cbf9
merge getUiPlugins and discover
mshustov Apr 8, 2020
1301220
static route declaration shouldnt require auth & validate
mshustov Apr 8, 2020
262a465
update docs
mshustov Apr 8, 2020
02d8315
use HttpResources service instad of rendering
mshustov Apr 8, 2020
6d0de20
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 14, 2020
40a9b7f
address comments
mshustov Apr 14, 2020
7f52fb3
update docs
mshustov Apr 14, 2020
02776eb
roll back unnecessary changes
mshustov Apr 14, 2020
c7712ac
use getVars for rendering
mshustov Apr 14, 2020
e01d8ff
dont pass app. it is not public API
mshustov Apr 14, 2020
54d3a70
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 14, 2020
be8380e
Merge branch 'master' into issue-50654-http-resources
mshustov Apr 16, 2020
9e58fe0
remove static registers
mshustov Apr 16, 2020
ce0b74e
update migration guide
mshustov Apr 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
<b>Signature:</b>

```typescript
http: HttpServiceSetup;
http: HttpServiceSetup & {
resources: HttpResources;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -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&lt;TPluginsStart, TStart&gt;</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 &amp; {</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) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResources](./kibana-plugin-core-server.httpresources.md)

## HttpResources interface

HttpResources service is responsible for serving static &amp; 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>&lt;P, Q, B&gt;(route: RouteConfig&lt;P, Q, B, 'get'&gt;, handler: HttpResourcesRequestHandler&lt;P, Q, B&gt;) =&gt; void</code> | To register a route handler executing passed function to form response. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResources](./kibana-plugin-core-server.httpresources.md) &gt; [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;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesRenderOptions](./kibana-plugin-core-server.httpresourcesrenderoptions.md) &gt; [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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [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. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [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) =<!-- -->&gt; { //.. return response.renderCoreApp(); }<!-- -->);

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesResponseOptions](./kibana-plugin-core-server.httpresourcesresponseoptions.md)

## HttpResourcesResponseOptions type

HTTP Resources response parameters

<b>Signature:</b>

```typescript
export declare type HttpResourcesResponseOptions = HttpResponseOptions;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [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) =&gt; Promise&lt;IKibanaResponse&gt;</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) =&gt; Promise&lt;IKibanaResponse&gt;</code> | To respond with HTML page bootstrapping Kibana application. |
| [renderHtml](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderhtml.md) | <code>(options: HttpResourcesResponseOptions) =&gt; IKibanaResponse</code> | To respond with a custom HTML page. |
| [renderJs](./kibana-plugin-core-server.httpresourcesservicetoolkit.renderjs.md) | <code>(options: HttpResourcesResponseOptions) =&gt; IKibanaResponse</code> | To respond with a custom JS script file. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) &gt; [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>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) &gt; [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>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) &gt; [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;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [HttpResourcesServiceToolkit](./kibana-plugin-core-server.httpresourcesservicetoolkit.md) &gt; [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;
```
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IRouter
| --- | --- | --- |
| [delete](./kibana-plugin-core-server.irouter.delete.md) | <code>RouteRegistrar&lt;'delete'&gt;</code> | Register a route handler for <code>DELETE</code> request. |
| [get](./kibana-plugin-core-server.irouter.get.md) | <code>RouteRegistrar&lt;'get'&gt;</code> | Register a route handler for <code>GET</code> request. |
| [handleLegacyErrors](./kibana-plugin-core-server.irouter.handlelegacyerrors.md) | <code>&lt;P, Q, B&gt;(handler: RequestHandler&lt;P, Q, B&gt;) =&gt; RequestHandler&lt;P, Q, B&gt;</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&lt;'patch'&gt;</code> | Register a route handler for <code>PATCH</code> request. |
| [post](./kibana-plugin-core-server.irouter.post.md) | <code>RouteRegistrar&lt;'post'&gt;</code> | Register a route handler for <code>POST</code> request. |
| [put](./kibana-plugin-core-server.irouter.put.md) | <code>RouteRegistrar&lt;'put'&gt;</code> | Register a route handler for <code>PUT</code> request. |
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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&lt;string, unknown&gt;</code> | |
| [uiPlugins](./kibana-plugin-core-server.legacyservicesetupdeps.uiplugins.md) | <code>UiPlugins</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyServiceSetupDeps](./kibana-plugin-core-server.legacyservicesetupdeps.md) &gt; [uiPlugins](./kibana-plugin-core-server.legacyservicesetupdeps.uiplugins.md)

## LegacyServiceSetupDeps.uiPlugins property

<b>Signature:</b>

```typescript
uiPlugins: UiPlugins;
```
Loading