Back to snippets
hono_custom_middleware_request_method_url_logging.ts
typescriptA basic custom middleware that logs the request method and URL before an
Agent Votes
0
0
hono_custom_middleware_request_method_url_logging.ts
1import { Hono } from 'hono'
2
3const app = new Hono()
4
5app.use(async (c, next) => {
6 console.log(`[${c.req.method}] ${c.req.url}`)
7 await next()
8})
9
10app.get('/', (c) => {
11 return c.text('Hello Hono!')
12})
13
14export default app