+7
日增长
9,634
stars
445
forks
51
watchers
966
prs
625
issues
13
releases
README
欢迎来到 Loco
--
🚂 Loco is Rust on Rails.
--
English · 中文 · Français · Portuguese (Brazil) ・ 日本語 · 한국어 · Русский · Español · Vietnamese · العربية · Bahasa Indonesia
什么是 Loco?
Loco 深受 Rails 启发。如果你熟悉 Rails 和 Rust,使用 Loco 会得心应手。如果你熟悉 Rails 但刚接触 Rust,Loco 也会让你耳目一新。使用 Loco 并不要求你预先了解 Rails。
深入了解 Loco 的工作原理,包括详细指南、示例和 API 参考,请访问我们的文档网站。
Loco 的特性
约定优于配置: 与 Ruby on Rails 类似,Loco 注重简洁与开发效率,尽量减少样板代码。它提供合理的默认配置,让开发者把精力放在业务逻辑上,而非繁琐的配置工作上。
快速开发: Loco 通过减少样板代码和提供直观的 API 来提高开发效率,使开发者能够快速迭代,并以更少的工作量构建原型。
ORM 集成: 使用可靠的实体模型描述业务,无需编写 SQL。可以直接在实体上定义关系、验证规则和自定义逻辑,从而提升可维护性和可扩展性。
控制器(Controllers): 处理 Web 请求参数、请求体和验证,并渲染与内容类型相匹配的响应。我们使用 Axum,以获得最佳的性能、简洁性和可扩展性。控制器还让你能够轻松构建中间件,在请求传递给主要的控制器处理函数之前,加入身份验证、日志记录或错误处理等逻辑。
视图(Views): Loco 可以与模板引擎集成,根据模板生成动态 HTML 内容。
后台作业(Background Jobs): 借助 Redis 支持的队列或线程,在后台执行计算密集型或 I/O 密集型作业。要实现一个 worker,只需为 Worker trait 实现 perform 函数。
调度器(Scheduler): 简化传统而繁琐的 crontab 系统,让任务或 shell 脚本的定时执行更简单、更优雅。
邮件(Mailers): mailer 会利用 Loco 现有的后台 worker 基础设施,在后台发送电子邮件,整个过程都能无缝完成。
存储(Storage): Loco Storage 提供多种文件操作,简化文件处理。文件可以存储在内存或磁盘中,也可以使用 AWS S3、GCP 和 Azure 等云服务。
缓存(Cache): Loco 提供缓存层,通过存储频繁访问的数据来提升应用性能。
了解 Loco 的更多特性,请访问我们的文档网站。
快速开始
--
sh
cargo install loco
cargo install sea-orm-cli Only when DB is needed
--
现在可以创建新应用了(选择“SaaS 应用”)。
--
sh
❯ loco new
✔ ❯ App name? · myapp
✔ ❯ What would you like to build? · Saas App with client side rendering
✔ ❯ Select a DB Provider · Sqlite
✔ ❯ Select your background worker type · Async (in-process tokio async tasks)
🚂 Loco app generated successfully in:
myapp/
- assets: You've selected clientside for your asset serving configuration.
Next step, build your frontend:
$ cd frontend/
$ npm install && npm run build
--
现在进入 myapp 目录并启动应用:
--
sh
$ cargo loco start
▄ ▀
▀ ▄
▄ ▀ ▄ ▄ ▄▀
▄ ▀▄▄
▄ ▀ ▀ ▀▄▀█▄
▀█▄
▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▀▀█
██████ █████ ███ █████ ███ █████ ███ ▀█
██████ █████ ███ █████ ▀▀▀ █████ ███ ▄█▄
██████ █████ ███ █████ █████ ███ ████▄
██████ █████ ███ █████ ▄▄▄ █████ ███ █████
██████ █████ ███ ████ ███ █████ ███ ████▀
▀▀▀██▄ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ██▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
https://loco.rs
listening on port 5150
--
由 Loco 驱动的应用
SpectralOps - 多项服务由 Loco 框架驱动
Nativish - 应用后端由 Loco 框架驱动
贡献者 ✨
感谢这些优秀的贡献者:Top issues
#1714Contribute rhai-loco to this org21 comments · 2025-12-22#1856Admin dashboard11 comments · 2026-10-13#1859Unmaintained unsafe-libyaml (RUSTSEC-2024-0449) via serde_yaml_ng and loco-gen/rrgen3 comments · 2026-10-16#1766Rails style migrations3 comments · 2026-05-13#1893Web site documentation is hard to read | Make it more readable (suggestion and idea)1 comments · 2026-10-30#1720Support having custom field types on models when using entity generation1 comments · 2025-12-31#1905Db seed0 comments · 2026-11-14#1904CI: pin actions to commits, add coverage and security checks, and run zanadir0 comments · 2026-11-14
Discussions
#1888Guest article idea: Testing an agent-facing Loco endpoint0 comments · 2026-10-24#1836Loco 1.2.00 comments · 2026-09-24#1833Onboard experience0 comments · 2026-09-21#1796VSCode Snippets Extension for Rust Loco0 comments · 2026-08-03#1793Migration of PKs to 1.01 comments · 2026-08-02#1781No new updates?1 comments · 2026-07-25#1769How to run the app from another dir other than root working directory?1 comments · 2026-05-29#1765Plan for Next Release?1 comments · 2026-05-05
Latest release
v1.3.1 v1.3.1 2026-11-06Fixed - SQLite apps could fail to boot with PoolTimedOut. 1.3.0 runs the PRAGMAs on every new connection, and some of them read the database file, so opening a connection waits on any other connection's lock for up to busy_timeout. That wait counted against connect_timeout (500ms in generated test configs), so a busy file failed boot instead of waiting. SQLite pools now allow busy_timeout on top of the acquire timeout. Seen as intermittent test failures, mostly on CI and Windows.