-
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
Introduce HttpApi and HttpResource services #44620
Comments
Pinging @elastic/kibana-platform |
What do you think about creating two lightweight services in front of http and exposing them to plugins instead of http directly? Both would use the HttpService behind the scenes. APIServiceThis would expose a BrowserResourceServiceI'm open to naming on this one, but it would effectively be a GET-only router interface over the HTTPService with the ability to optionally define a "root" resource. |
@epixa It makes a lot of sense and aligned with an approach proposed in #21424
Do we want to distinguish between public and internal API endpoints? as discussed in #21424. I'd assume we want to use OpenAPI for both, but without BWC guarantees for internal API. In this case, we may want to use different prefixes for them. httpAPIService.add({
path: 'resource-name', // served under `/api/{pluginId}/resource-name`
public: true,
handler(){}
});
There are different cases for static resources:
httpResourceService.add({
path: 'resource-name', // server under '/resource-name/'
fromRoot: true,
handler(){}
});
httpResourceService.add({
path: 'resource-name', // server under '/{pluginId}/resource-name/'
directory: ...
}); @elastic/kibana-platform |
Personally, I'm in favor of this, but from a pragmatic standpoint, I think it's best if we decouple that effort from this. We know in 7.x we need to support a more free-form route definition that isn't tied to Open API, and ease-of-migration seems paramount in the short term. I do think having the ApiService already exist is a step in the right direction though. What do you think?
I'm not aware of any plugins providing straight HTML pages at the moment. I'm aware of four places where we use a root resource today:
I think I'd be happy with most solutions that keep these things working and makes migration as easy as possible. Either way, having a dedicated service for this seems to make sense, no?
I don't see a concrete reason to allow root-level static resources, or at least I'm not familiar with any such usage today. I think we have traditionally not put constraints on how plugins expose their static resources, but that seems like a sensible thing to do down the line. Again, so long as migration is easy, I don't think we can go wrong here. |
Yes, maintaining different route declarations for
|
I'm a proponent of the different services approach as well. Though they are all built on HTTP, the concerns of each area are different and we have plans to evolve at least one of those (OpenAPI) pretty extensively. In the short term, how do we feel about changing the |
We should leverage this service to enforce the API conventions listed in the styleguide:
|
Canvas had some issues on Cloud with serving a static resource that we have that is created as part of the build process. Wanted to make sure we don't run into a similar issues when we move to using Resource Service in the future. See #49538 for what the final solution was and links to the issues we went through. |
Kibana should have the ability to distinguish between API calls/resource loading, as they have different URL rules and authorization rules.
For this, we are going to provide 2 different services working on top of the HTTP service.
HttpApiService
This would expose a
createRouter
function that is already prefixed with/api/<plugin-name>
. Supports multiple routes registering (more details #44174)In the future, this contract would evolve to be Open API oriented.
HttpResourceService
There are 2 different cases for static resources:
/my-page/
.Original description
In New platform, we force plugins to defines their routes prefixed with plugin id (`/security/api` for example). When plugin migrates to New Platform, it will introduce breaking changes in minor versions, because plugin api will be moved from `api/{pluginName}/...` to `{pluginName}/...` . Also, there are page routes like `/login` and `/logout` that we can't be moved at least until major version as well.
I originally planned to force prefixed url registration in the new platform and set up a proxy to legacy url for BWC. But on the 7.5 planning meeting, we discussed that we are going to drop server side of the Legacy platform ~
v7.7
. So now I'm inclining towards temporarily introducing an additional route configuration option that allows creating a route relative to the root url withoutplugin id prefix
.This option will be used only for BWC as a part of #40768. We can safely remove it from a public interface just before
v8
release.Any other ideas?
The text was updated successfully, but these errors were encountered: