Express 延长Ktor的路线

Express 延长Ktor的路线,express,ktor,Express,Ktor,我希望能够写一条路线,防止自己重复我自己。例如。如果我创建了一个在db中查找用户的路由,那么在另一个api中使用用户信息。我想将路线作为一个函数使用,但仍将其作为路线使用。例如,我在express中就是这样做的 exports.getUserById = function(req, res, next) { // Code goes here. I first check whether the user exist`s or not so I dont write the logic agai

我希望能够写一条路线,防止自己重复我自己。例如。如果我创建了一个在db中查找用户的路由,那么在另一个api中使用用户信息。我想将路线作为一个函数使用,但仍将其作为路线使用。例如,我在express中就是这样做的

exports.getUserById = function(req, res, next) { // Code goes here. I first check whether the user exist`s or not so I dont write the logic again}`
exports.getUserCompany = function(req, res, next) { //I use the data from getUserById by caching it in the request as req.resources.user }
exports.updateCompany = function(req, res, next) { //Use info from the getUserCompany controller. }
` //路由

app.routes('api/user/:id/company').get(controller.getUserById, controller.getUserCompany)
app.routes('api/user/:id/company/:company_id/update').put(controller.getUserById, controller.getUserCompany, controller.updateCompany)
`