如何在Loopback 4应用程序中使用HTTP2?
我们计划在Loopback 4应用程序中实现HTTP2。我们使用过HTTP,套接字服务器,但从未使用过HTTP2。
在我的应用程序中使用HTTP2的过程是什么?
We are planning to implement http2 in a loopback 4 application. We had used http, socket servers but never http2.
What is the procedure to use http2 in my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您在现有应用中必须要做的:
步骤1:安装 spdy spdy
步骤2:配置
index.ts
更改您的主函数:
在
src/index.ts
中 防止默认的HTTP服务器使用loopback的请求处理程序app.requesthandler
使用SPDY启动并启动服务器,该将用于所有传入请求。要生成本地主机的证书和键:
您可能需要在Chrome中允许自签名证书以及
/explorer
按预期工作。就是这样,您现在可以运行应用程序,并享受http2的功能:)
博客文章: https://shubham-web.medium.com/how-to-use-http2-in-loopback-4-applications-5e8381c7b38
Here's what you have to do in your existing app:
Step 1: Install spdy
Step 2: Configure
index.ts
Change your main function in
src/index.ts
with this:All we're doing in the above code is, preventing the default http server from being started and starting the server using spdy with loopback's request handler
app.requestHandler
that will be used for all incoming request.To generate certificate and keys for localhost use:
You may need to allow self-signed certificates in Chrome as well for
/explorer
to work as expected.And that's it, you can now run your app, and enjoy the power of http2 :)
Blog Post: https://shubham-web.medium.com/how-to-use-http2-in-loopback-4-applications-5e83881c7b38