Skip to content

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

Merged
mshustov merged 11 commits intoelastic:masterfrom
mshustov:create-router-http
Aug 9, 2019
Merged

Expose createRouter from HttpService, prepare handlers for context introduction#42686
mshustov merged 11 commits intoelastic:masterfrom
mshustov:create-router-http

Conversation

@mshustov
Copy link
Copy Markdown
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
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// labels Aug 8, 2019
@elasticmachine
Copy link
Copy Markdown
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
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@mshustov mshustov requested a review from joshdover August 9, 2019 10:29
@elasticmachine
Copy link
Copy Markdown
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 backported release_note:skip Skip the PR/issue when compiling release notes and removed review 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
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v7.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants