-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Document how to extend request handler context #53271
Document how to extend request handler context #53271
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
retest |
retest |
[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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about this one
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'); | ||
... | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
};
};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I did not see the declare module 'src/core/server'
statement
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…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)
Summary
Closes #47689
Document what is provided via request handler context & how to extend it with custom API.