-
-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CBOR #3648
Comments
Hi @3w36zj6 It's interesting. Does it need external libraries? |
There is quite a bit of lines... |
I think we can use Code example: import { Hono } from 'hono'
import { createMiddleware } from 'hono/factory'
const app = new Hono()
declare module 'hono' {
interface ContextRenderer {
(content: any): Response | Promise<Response>
}
}
const renderer = createMiddleware(async (c, next) => {
c.setRenderer((content) => {
return c.body(encodeCBOR(content))
})
await next()
})
app.use(renderer)
app.get('/', (c) => {
return c.render({ foo: 'bar' })
})
export default app So, if the implementation is not too complicated, we may not provide the middleware and can write the instructions on our website. |
As an example of utilizing IMO: CBOR has related RFCs such as CBOR Sequences (RFC 8742), COSE (RFC 9053), and CWT (RFC 8392). Considering future support for these, I think it would be preferable to manage reusable code and calls to other third-party middleware centrally through CBOR Middleware/Helper. |
What is the feature you are proposing?
CBOR is a binary format for serializing objects defined in RFC 8949. It is JSON-compatible and suitable for network communications that require efficient data exchange, as well as for use in resource-constrained environments such as IoT devices.
I would be happy to assist if there is anything I can help with. If there are concerns about supporting CBOR in the Hono core package, I am considering creating a helper as third-party middleware first.
The text was updated successfully, but these errors were encountered: