/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-don-t-make-controll-f6a3c362a69a-don-t-make-controllers-when-possible-s0076-c0000.md
Don't make "Controllers" when possible - hono-docs
Don't make "Controllers" when possible Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt don t make...
Don't make "Controllers" when possible
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#don-t-make-controllers-when-possible
Summary
When possible, you should not create "Ruby on Rails-like Controllers". ts // 🙁 // A RoR-like Controller const booksList = (c: Context) => { return c.json('list books') } app.get('/books', booksList) The issue is related to types....
Content
When possible, you should not create "Ruby on Rails-like Controllers".
// 🙁
// A RoR-like Controller
const booksList = (c: Context) => {
return c.json('list books')
}
app.get('/books', booksList)The issue is related to types. For example, the path parameter cannot be inferred in the Controller without writing complex generics.
// 🙁
// A RoR-like Controller
const bookPermalink = (c: Context) => {
const id = c.req.param('id') // Can't infer the path param
return c.json(`get ${id}`)
}Therefore, you don't need to create RoR-like controllers and should write handlers directly after path definitions.
// 😃
app.get('/books/:id', (c) => {
const id = c.req.param('id') // Can infer the path param
return c.json(`get ${id}`)
})