Document how to extend request handler context#53271
Merged
mshustov merged 6 commits intoelastic:masterfrom Dec 19, 2019
Merged
Document how to extend request handler context#53271mshustov merged 6 commits intoelastic:masterfrom
mshustov merged 6 commits intoelastic:masterfrom
Conversation
Contributor
|
Pinging @elastic/kibana-platform (Team:Platform) |
Contributor
Author
|
retest |
Contributor
Author
|
retest |
pgayvallet
reviewed
Dec 17, 2019
Comment on lines
+3
to
+5
| [Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Logger](./kibana-plugin-server.logger.md) > [get](./kibana-plugin-server.logger.get.md) | ||
|
|
||
| ## Logger.get() method |
Comment on lines
+1472
to
+1481
| core.http.registerRouteHandlerContext('myPlugin', (context, req, res) => { | ||
| return { client: client.asScoped(req) }; | ||
| }); | ||
|
|
||
| router.get( | ||
| { path: '/api/my-plugin/', validate }, | ||
| async (context, req, res) => { | ||
| const data = await context.myPlugin.client.callAsCurrentUser('endpoint'); | ||
| ... | ||
| } |
Contributor
There was a problem hiding this comment.
TIL
Does that works without casting context to any though ?
export type RequestHandler<
P extends ObjectType,
Q extends ObjectType,
B extends ObjectType | Type<Buffer> | Type<Stream>,
Method extends RouteMethod = any
> = (
context: RequestHandlerContext,
request: KibanaRequest<TypeOf<P>, TypeOf<Q>, TypeOf<B>, Method>,
response: KibanaResponseFactory
) => IKibanaResponse<any> | Promise<IKibanaResponse<any>>;export interface RequestHandlerContext {
core: {
savedObjects: {
client: SavedObjectsClientContract;
};
elasticsearch: {
dataClient: IScopedClusterClient;
adminClient: IScopedClusterClient;
};
uiSettings: {
client: IUiSettingsClient;
};
};
}
Contributor
There was a problem hiding this comment.
Nevermind, I did not see the declare module 'src/core/server' statement
pgayvallet
approved these changes
Dec 17, 2019
Contributor
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
mbondyra
added a commit
to mbondyra/kibana
that referenced
this pull request
Dec 19, 2019
…f github.com:mbondyra/kibana into IS-51910_share-lens-change-index-pattern-in-discover * 'IS-51910_share-lens-change-index-pattern-in-discover' of github.com:mbondyra/kibana: [Discover] Remove angular field filter template code (elastic#53513) [APM] Improve table and other panel loading states (elastic#53459) Security/Spaces - cleanup react warnings (elastic#53287) Revert "NP licensing add functional tests (elastic#53002)" (elastic#53577) NP licensing add functional tests (elastic#53002) fix onLicenseInfoChange callback to be called on update (elastic#53559) Document how to extend request handler context (elastic#53271)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #47689
Document what is provided via request handler context & how to extend it with custom API.