Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.69 KB

kibana-plugin-server.router.md

File metadata and controls

45 lines (29 loc) · 1.69 KB

Home > kibana-plugin-server > Router

Router class

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 

Constructors

Constructor Modifiers Description
(constructor)(path) Constructs a new instance of the Router class

Properties

Property Modifiers Type Description
path string

Methods

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.

Example

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' }));