Kind: Function
Source: src/adapter/deno/conninfo.ts
Part of: Adapter
Get conninfo with Deno
getConnInfo reads connection details from the Deno request environment for a Hono context. It returns the remote and local address information associated with the current request, allowing handlers to inspect client and server connection data.
Signature
tsfunction getConnInfo(c)
Parameters
| Name | Type |
|---|---|
c | any |
Diagram
mermaidgraph LR Request[Deno request] --> Context[Hono context] Context --> Environment[Deno connection environment] Environment --> getConnInfo[getConnInfo] getConnInfo --> ConnInfo[Remote and local connection info]
Usage
tsimport { Hono } from 'hono'
import { getConnInfo } from 'hono/conninfo'
const app = new Hono()
app.get('/connection', (c) => {
const connInfo = getConnInfo(c)
return c.json({
remote: connInfo.remote,
local: connInfo.local,
})
})
Deno.serve(app.fetch)
AI Coding Instructions
- Call
getConnInfowith the current HonoContextinside a request handler. - Treat connection addresses as request metadata and account for missing address fields where deployment environments do not expose them.
- Keep Deno-specific connection handling within the Deno adapter rather than reading adapter environment values directly in shared application code.
- Import the connection helper from
hono/conninfoso the matching runtime implementation is selected.
Was this page helpful?