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

Expose createRouter from HttpService, prepare handlers for context introduction #42686

Merged
merged 11 commits into from
Aug 9, 2019

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Aug 6, 2019

Summary

Added createRouter as a part of HttpService Setup contract.
It serves 2 purposes:

  1. Forces all resources exposed by a plugin to be prefixed with plugin name. Core services may registered any urls.
  const router = createRouter();
  // handler is called when '${my-plugin-id}/path' resource is requested with `GET` method
  router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' }));
  1. Restricts access to plugin dependencies within handler context.
  const router = createRouter();
  
  router.get({ path: '/path', validate: false }, (context, req, res) => {
    // has access to `findObject` method of context, exposed by core service, plugin itself or plugin dependencies 
    const data = await context.findObject(request.params.id);
    return response.ok(data);
  };

Dev docs are covered by #41894

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@mshustov mshustov added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Aug 8, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@mshustov mshustov marked this pull request as ready for review August 8, 2019 13:56
@mshustov mshustov requested review from a team as code owners August 8, 2019 13:56
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

src/core/server/plugins/plugin_context.ts Outdated Show resolved Hide resolved
src/core/server/http/router/router.ts Outdated Show resolved Hide resolved
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov requested a review from joshdover August 9, 2019 10:29
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov merged commit c9220c5 into elastic:master Aug 9, 2019
@mshustov mshustov deleted the create-router-http branch August 9, 2019 19:08
mshustov added a commit to mshustov/kibana that referenced this pull request Aug 10, 2019
…troduction (elastic#42686)

* expose createRouter, prepare route handler for context introduction.

* fix tests

* update examples in docs

* update tests

* re-genereated docs

* remove registerRouter from http service contract

createRouter registers a router under the hood. that reduces API surface
for consumers

* address comments

* update docs
mshustov added a commit that referenced this pull request Aug 10, 2019
…troduction (#42686) (#43072)

* expose createRouter, prepare route handler for context introduction.

* fix tests

* update examples in docs

* update tests

* re-genereated docs

* remove registerRouter from http service contract

createRouter registers a router under the hood. that reduces API surface
for consumers

* address comments

* update docs
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 12, 2019
…p-metrics-selectall

* 'master' of github.com:elastic/kibana: (22 commits)
  [Code]: downgrade the log level of error message from subprocess (elastic#42925)
  [Code] Cancel clone/update job in the middle if disk space over the watermark (elastic#42890)
  Add Kibana App specific URL to the help menu (elastic#34739) (elastic#42580)
  [Maps] refactor createShapeFilterWithMeta to support more than just polygons (elastic#43042)
  Skip flaky es_ui_shared/request tests.
  Pass uiSettings to all data plugin services (elastic#42159)
  [SIEM] Upgrades react-redux and utilize React.memo for performance gains  (elastic#43029)
  [skip-ci][Maps] add maki icon sheet to docs (elastic#43063)
  Adding "style-src 'unsafe-inline' 'self'" to default CSP rules (elastic#41305)
  Update dependency commander to v3 (elastic#43041)
  Update dependency @percy/agent to ^0.10.0 (elastic#40517)
  [Maps] only show top hits checkbox if index has date fields (elastic#43056)
  run chained_controls on Firefox to catch regression (elastic#43044)
  fixing issue with dashboard csv download (elastic#42964)
  Expose task manager as plugin instead of server argument (elastic#42966)
  Expose createRouter from HttpService, prepare handlers for context introduction (elastic#42686)
  [Code] disk watermark supports percentage and absolute modes (elastic#42987)
  [apps/dashboard] skip part of filtering tests on FF (elastic#43047)
  [ML] Kibana management jobs list (elastic#42570)
  [ML] Fix check for watcher being enabled (elastic#43025)
  ...
@mshustov mshustov added release_note:skip Skip the PR/issue when compiling release notes and removed release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. labels Aug 14, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants