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
Response factory parameters as named arguments #43248
Conversation
Pinging @elastic/kibana-platform |
💚 Build Succeeded |
💚 Build Succeeded |
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.
Makes the API much nicer :D
@@ -71,7 +69,10 @@ export type HttpResponsePayload = undefined | string | Record<string, any> | Buf | |||
* HTTP response parameters for a response with adjustable status code. | |||
* @public | |||
*/ | |||
export interface CustomHttpResponseOptions extends HttpResponseOptions { | |||
export interface CustomHttpResponseOptions<T extends HttpResponsePayload | ResponseError> { | |||
body?: T; |
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.
nit: For completeness sake maybe we should add a doc comment here too
/** HTTP message to send to the client */
src/core/server/server.api.md
Outdated
export interface CustomHttpResponseOptions<T extends HttpResponsePayload | ResponseError> { | ||
// (undocumented) | ||
body?: T; | ||
// Warning: (ae-forgotten-export) The symbol "ResponseHeaders" needs to be exported by the entry point index.d.ts |
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.
Missing type export
// (undocumented) | ||
data?: Record<string, any>; | ||
// (undocumented) | ||
docLink?: string; |
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.
I really liked the idea of typing API best practices like this. It's not critical now, but hopefully we can re-introduce this at some point when we can make breaking changes with HAPI.
f55dee7
to
379e6f4
Compare
💚 Build Succeeded |
…ature # Conflicts: # docs/development/core/server/kibana-plugin-server.md # src/core/server/http/http_server.test.ts # src/core/server/http/integration_tests/core_services.test.ts
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
* pass body as response parameter. use attributes for error responses * update core * update tests * update x-pack code * update x-pack tests * regen docs * update comment * Review feedback and fixes after master merge * Eslint fixes
Summary
There are 2 changes
attributes
property of error object. for BWC with Boom error schema.Dev docs are covered by #41894
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers