Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 1022 Bytes

kibana-plugin-core-server.httpservicesetup.createrouter.md

File metadata and controls

27 lines (16 loc) · 1022 Bytes

Home > kibana-plugin-core-server > HttpServiceSetup > createRouter

HttpServiceSetup.createRouter property

Provides ability to declare a handler function for a particular path and HTTP request method.

Signature:

createRouter: <Context extends RequestHandlerContext = RequestHandlerContext>() => IRouter<Context>;

Remarks

Each route can have only one handler function, which is executed when the route is matched. See the IRouter documentation for more information.

Example

const router = createRouter();
// handler is called when '/path' resource is requested with `GET` method
router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' }));