【Hacker News搬运】展示HN:Rust Web框架
-
Title: Show HN: Rust Web Framework
展示HN:Rust Web框架
Text: Hi everyone,<p>I've been "funemployed" for a few months and with all that free time and idle hands I wrote a full web framework (think Rails, not Flask) for Rust.<p>It's boring old MVC, has its own ORM, templates, background jobs, auth, websockets, migrations and more. If you're keen but don't feel like rewriting your app in a different language, Rwf has a WSGI server to run Django (or Flask) inside Rust [1], letting you migrate to Rust at your own pace without disrupting your website.<p>I think Rust makes a great prototyping and deploy straight to production language. Now it has yet another framework for y'all to play with.<p>Cheers!<p>[1] <a href="https://levkk.github.io/rwf/migrating-from-python/" rel="nofollow">https://levkk.github.io/rwf/migrating-from-python/</a>
大家好,<p>我;已经";失业";在几个月的时间里,利用所有的空闲时间和空闲的双手,我为Rust编写了一个完整的web框架(想想Rails,而不是Flask)<p> 它;它是一个无聊的旧MVC,有自己的ORM、模板、后台作业、身份验证、websockets、迁移等等。如果您;我很感兴趣,但不喜欢;Rwf不想用另一种语言重写你的应用程序,它有一个WSGI服务器在Rust中运行Django(或Flask)[1],让你可以按照自己的节奏迁移到Rust,而不会中断你的网站<p> 我认为Rust是一种很好的原型设计和直接部署到生产环境的语言。现在,它有了另一个y框架;都是用来玩的<p> 干杯<p> [1]<a href=“https:/;levkk.github.ioH;rwfG;从python迁移+;rel=“nofollow”>https:"/;levkk.github.io;rwf;从python迁移</一
Url: https://github.com/levkk/rwf
很抱歉,作为一个文本和信息处理的AI,我无法直接访问或处理GitHub链接或任何外部网站内容。不过,我可以根据你提供的链接信息来帮助你理解。 GitHub链接 `https://github.com/levkk/rwf` 指的是GitHub上一个名为 "rwf" 的项目,由用户 `levkk` 创建。以下是基于项目名称和通常的GitHub项目命名习惯的推测: 1. **项目名称分析**:`rwf` 可能代表 "read write file",这可能意味着项目是关于文件读写操作的。 2. **可能的项目内容**:该项目可能包含以下内容: - 文件读写相关的代码示例。 - 文件处理库或模块。 - 文件格式解析或转换工具。 - 与文件系统交互的应用程序。 由于我无法访问项目具体内容,以下是对项目可能内容的中文总结: 该项目可能是一个关于文件操作的库或工具,包括文件的读取和写入功能。它可能提供了一系列的API或函数来帮助开发者方便地处理文件读写任务。这可能包括文本文件的读写、二进制文件的读写、文件格式转换等功能。 如果项目包含非中文内容,您可以使用在线翻译工具将项目文档或代码翻译成中文,以便更好地理解和使用该项目。例如,您可以使用Google翻译、DeepL等在线翻译服务来翻译项目说明、代码注释等。
Post by: levkk
Comments:
imiric: After years of working with web frameworks in Python and Java, and then picking up Go along the way, I've come to appreciate Go's approach much more. That is, with a rich and capable standard library, you really don't need traditional frameworks. Need an HTTP server, router, etc.? Use stdlib. Need templates? Use stdlib. Need an ORM? You don't, but you may want to consider a small 3rd party query builder library of your choice. And so on.<p>This avoids depending on a complex framework that may or may not exist in a few years, improves security by minimizing the amount of 3rd party dependencies, keeps the learning curve low for any new developers joining the project, and is more flexible and easier to maintain. I don't have experience with Rust, and judging by the comments here, web frameworks might still be useful for it. Which is a shame, since the batteries included stdlib approach is far superior IME.<p>Anyway, I don't want to shoot down your efforts. Congrats on the launch and good luck!
imiric: 经过多年使用Python和Java的web框架,然后一路学习Go,我;我开始欣赏Go;s的方法要多得多。也就是说,有了丰富而强大的标准库,你真的不需要;不需要传统的框架。需要HTTP服务器、路由器等吗。?使用stdlib。需要模板吗?使用stdlib。需要ORM吗?你不知道;t、 但您可能想考虑选择一个小型的第三方查询构建器库。等等。<p>这避免了依赖于几年后可能存在或不存在的复杂框架,通过最大限度地减少第三方依赖关系来提高安全性,使加入项目的任何新开发人员的学习曲线保持较低水平,并且更灵活、更易于维护。我不知道;我对Rust没有经验,从这里的评论来看,web框架可能仍然对它有用。这很遗憾,因为包含电池的stdlib方法远远优于IME<p> 不管怎样,我不知道;我不想贬低你的努力。恭喜发射,祝你好运!
kvirani: Nice, congratulations. It must feel so surreal launching this!<p>One of my biggest learnings from doing a bunch of web MVC through Rails over the years is that the framework should heavily discourage business logic in the model layer.<p>Some suggestions:<p>- Don't allow "callbacks" (what AR calls them) ie hooks like afterCreate in the data model. I know you don't have these yet in your ORM, but in case those are on the roadmap, my opinion is that they should not be.<p>- That only really works though if you not strongly encourage a service aka business logic layer. Most of my Rails app tend to have all of these as command aka service objects using a gem (library/package) like Interactor.<p> It's my view that MVC (and therefore Rails otb) is not ideal by itself to write a production-ready app, because of the missing service layer.<p>Also, curious why existing ORMs or query builders from the community weren't leveraged?<p>Disclaimer: I haven't written a line of Rust yet (more curious as the days go by). I'm more curious than ever now, thanks to you!
kvirani: 很好,恭喜你。推出这个一定感觉很超现实<p> 多年来,我通过Rails做了一堆web MVC,最大的收获之一是,该框架应该严重阻碍模型层中的业务逻辑<p> 一些建议:<p>-不要;不允许";回调”;(AR称之为)(数据模型中类似afterCreate的钩子。我知道你不知道;你的ORM中还没有这些,但如果这些已经在路线图上,我的观点是不应该。<p>-只有当你不强烈鼓励服务(即业务逻辑层)时,这才真正有效。我的大多数Rails应用程序倾向于使用像Interactior这样的gem(库/;包)将所有这些作为命令即服务对象;我认为MVC(以及Rails otb)本身并不是编写生产就绪应用程序的理想选择,因为缺少服务层<p> 此外,我很好奇为什么社区中现有的ORM或查询构建器不是;t杠杆<p> 免责声明:我没有;我还没有写一行Rust(随着时间的推移,这更奇怪)。我;多亏了你,我现在比以往任何时候都更好奇了!
throwaway313373: I would kinda expect REST framework to be able to generate Swagger (aka OpenAPI) definitions out of the box. That's one of the killer features of FastAPI in my opinion.<p>Also, I don't really understand what is the reason for creating your own ORM instead of integrating with, let's say diesel.rs [0] and what is the reason for inventing your own template language instead of just picking one of the most popular existing template engines [1].<p>Other than that this project looks really interesting and I will definitely keep an eye on it.<p>[0] <a href="https://diesel.rs/" rel="nofollow">https://diesel.rs/</a><p>[1] <a href="https://crates.io/categories/template-engine" rel="nofollow">https://crates.io/categories/template-engine</a>
throwaway313373: 我希望REST框架能够开箱即用地生成Swagger(又名OpenAPI)定义。那;在我看来,这是FastAPI的杀手级功能之一<p> 此外,我不知道;我真的不明白创建自己的ORM而不是与集成的原因是什么,让;s said diesel.rs[0]以及发明自己的模板语言而不是选择现有最流行的模板引擎之一的原因是什么[1]<p> 除此之外,这个项目看起来真的很有趣,我一定会关注它。<p>[0]<a href=“https:”diesel.rs“rel=”nofollow“>https:”/;柴油</a> <p>[1]<a href=“https:”crates.io“categories”模板引擎“rel=”nofollow“>https:”/;板条箱.io;类别;模板引擎</a>
stackskipton: As SRE, I got interested in <a href="https://levkk.github.io/rwf/migrating-from-python/" rel="nofollow">https://levkk.github.io/rwf/migrating-from-python/</a>. On one hand, this is crazy neat you were able to pull it off. On the stability SRE hand, I'm internally screaming. At scale, this should be handled by Reverse Proxy (Caddy, Nginx, Traefik, whatever)
stackskipton: 作为SRE,我对<a href=“https:”levkk.github.io:”rwf:“从python迁移”rel=“nofollow”>https:”/;levkk.github.io;rwf;从python迁移</一一方面,你能够做到这一点真是太棒了。在稳定性SRE方面,我;我内心在尖叫。从规模上讲,这应该由反向代理(Caddy、Nginx、Traefik等)来处理
notamy: What an amazing name choice, certainly one way to end up at the top of search results :P<p>To be serious, good job!! Building a good framework is a shockingly large task, and it’s always nice to see people exploring the design space and trying for new ideas.
notamy: 这是一个多么棒的名字选择,当然是进入搜索结果顶部的一种方式:P<P>说真的,做得好!!构建一个好的框架是一项令人震惊的艰巨任务,看到人们探索设计空间并尝试新想法总是很好。