-
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
[Discuss] Add NP core.http.route #44174
Comments
Pinging @elastic/kibana-platform |
I just saw a recent PR from @elastic/apm-ui which also uses this |
@jfsiii I think you need @elastic/apm-ui (elastic/apm is a little too wide in this case as it includes agents/server). |
I'm not opposed to add proposed API, as it more generic, provides declarative API and supports multiple registration. |
I'm happy to submit a PR if that helps. I'd be sure to get agreement on what the interface should be, how to implement, test, etc before starting. Just let me know. |
@restrry I also like the proposed API and agree that it's better to only expose one way of registering routes. |
I don't have any problems with the proposed API, as long as there's only a single way to register a route, I'm happy. One slight advantage to the existing API is that we can change the types of the params a bit more easily to better fit the HTTP method. For example, a GET request shouldn't specify any validation schema for it's payload because it should not have one. In terms of priority, I don't think this is a blocker for anyone, but if there is a strong consensus for the proposed change, then we should do it sooner than later to avoid unnecessary churn. |
I believe we can use a discriminated union since the different types are all based on the value of the |
should be done as a part of #44620 |
This reminds me of the client-side
I see |
Bringing this discussion from Slack into an issue
Request: Add a function in NP core.http that behaves like hapi’s server.route i.e. accepts a config object (or array of objects)? It needn't be a 1:1 match with the hapi function. Just something that accepts a config object (or array of them) with the basic info needed (
method
,path
,validate
,options
,handler
, etc)The Integrations Manager plugin is currently using that approach to define routes.
It's also the method shown in the migration guide
kibana/src/core/MIGRATION.md
Lines 463 to 473 in 4de1acf
This declarative approach is quite nice for authors. They markup the various pieces of the routes, then pass it to a function which does The Right Thing ™️
It also allows a simple data structure to be passed into the plugin which is great for composition and testing.
I think there are many other benefits for both authors and the Platform team, but I'll wait to hear back before going further.
The text was updated successfully, but these errors were encountered: