Comments (3)
We were just talking about it! #189
If this comes true, we can write this way.
const route = app.route('/users')
route.post('/', validate(userValidation.createUser), userController.createUser)
We are planning to release the Hono including this feature. Maybe it's v1.2.0.
Before it is released, you can write like this:
const mid = async (c: Context, next) => {
await next()
c.header('x-custom', 'abc')
}
app.use('*', async (c, next) => {
if (c.req.method === 'GET') {
await mid(c, next)
} else {
await next()
}
})
app.get('/', (c) => {
return c.text('Hello')
})
Thank you!
from hono.
from hono.
We released v1.2.0 including new features.
https://github.com/honojs/hono/releases/tag/v1.2.0
You can write like this:
import { Hono, Route } from 'hono'
const app = new Hono()
const route = new Route()
route.post('/', validate(userValidation.createUser), userController.createUser)
app.route('/users', route)
from hono.
Related Issues (20)
- Cloudflare Pages Middleware HOT 2
- Codecov actions throw error (2) HOT 1
- Type for `output` in hono client route getting dropped HOT 2
- `outputFormat` supports Response HOT 1
- Development dependencies update HOT 1
- Unable to add middleware after creation: Can not add a route since the matcher is already built. HOT 10
- `c.req.valid` does not work in route without path HOT 7
- Abort does not work with bun HOT 4
- Handling empty slash slots in URL (Double slash) HOT 4
- Built-in validator formData parsing HOT 4
- `factory.createApp()` will initApp every time it get called and cause some middleware error HOT 3
- hono/compress throws TypeError: Can't modify immutable headers HOT 3
- getConnInfo Cannot destructure property 'remoteAddr' of 'c.env' as it is undefined. HOT 2
- feat: trailing-slash proxy to parsed path with same request HOT 1
- Timing middleware show warning if duplicated
- Unable to get form data from a POST on Cloudflare Pages HOT 2
- npm create hono@latest error at #assembleAndUpdateConfig HOT 4
- Abort is crashing the server in Bun HOT 4
- Can we generate an openapi schema from any existing hono app? HOT 3
- Max Even Listeners Exceeded: Possible Memory Leak -> On Not Found Route HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hono.