Home > kibana-plugin-server > Router
Provides ability to declare a handler function for a particular path and HTTP request method. Each route can have only one handler functions, which is executed when the route is matched.
Signature:
export declare class Router
Constructor | Modifiers | Description |
---|---|---|
(constructor)(path) | Constructs a new instance of the Router class |
Property | Modifiers | Type | Description |
---|---|---|---|
path | string |
Method | Modifiers | Description |
---|---|---|
delete(route, handler) | Register a route handler for DELETE request. |
|
get(route, handler) | Register a route handler for GET request. |
|
post(route, handler) | Register a route handler for POST request. |
|
put(route, handler) | Register a route handler for PUT request. |
const router = new Router('my-app');
// handler is called when 'my-app/path' resource is requested with `GET` method
router.get({ path: '/path', validate: false }, (req, res) => res.ok({ content: 'ok' }));