poem
axum
poem | axum | |
---|---|---|
32 | 156 | |
3,647 | 19,415 | |
1.0% | 2.4% | |
8.9 | 9.4 | |
8 days ago | 1 day ago | |
Rust | Rust | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
poem
-
Show HN: Rust Web Framework
https://github.com/poem-web/poem is one Rust framework with swagger definitions out of the box.
-
Rust needs a web framework for lazy developers
There is one: Poem[1]
The author mentions flask but looking at the "What we need section", I don't think flask covers those. I hate Djago with a passion but if those are the requirements, I think Django is the one that closely resembles what the author is describing. So Poem is not a good candidate either in that regard. Poem is all in all, something that closely resembles FastAPI, which is actually a complement. I've tried half a dozen rust web frameworks and they all come with a ton of boilerplate fiddling with the initial setup. Which is a problem if you want to get things done fast. In that regard, poem nails it. Yes, actix has a considerably better performance but unless you are aiming for sub-30 millisecond responses, then actix is not what you should be looking at to begin with. Also if you crave a Pydantic, there is a crate that sort of does that for you: https://crates.io/crates/poem-openapi
[1] https://github.com/poem-web/poem
-
Write OpenAPI with TypeSpec
TypeSpec is great, but if you're working with Rust and you're about to write a new project that will require an OpenApi spec sooner or later, I'd like to recommend a web framework that has spec generation baked in:
https://github.com/poem-web/poem (see poem_openapi)
All you need to do is derive a trait on your response structs and in return you get an almost perfectly generated spec. Unions, objects, enums are first class citizens.
Also, if you're from coming from PHP, the controllers feel very much like symfony controllers.
P.s. Please do recommend an ORM that would feel closer to doctrine. I miss doctrine.
-
What is the best API generator for Axum?
I've used FastAPI/Pydantic before as well and it was a very good experience. It has been a while since I used them though, so I forget exactly how they compare, but I do recall it wrote most of the OpenAPI spec. for you. I will also agree when I saw utoipa and aide they seemed to require more boilerplate even though I have not done an actual comparison. Poem, on the other hand, seems very neat and clean and doesn't have any duplication that I can see. Here is the [TODO example](https://github.com/poem-web/poem/blob/master/examples/openapi/todos/src/main.rs).
-
Looking for a Rust API with automatic documentation and good validation?
The example at https://github.com/poem-web/poem/tree/master/examples/openapi/auth-apikey works without issues for me.
-
What library to use for a Websocket Server?
'Poem', it turns to nicer to play with for me than 'Axum'. Example of web socket chat https://github.com/poem-web/poem/blob/master/examples/poem/websocket-chat/src/main.rs
-
Rest API framework in rust
If you need built-in OpenAPI support, I can recommend Poem.
-
(Recommendation Request) Rust REST API framework; similar to Python's FastAPI(Python)
If OpenAPI is important, then you may to consider https://github.com/poem-web/poem instead of axum. It isn't nearly as widely used, but it should still be compatible with everything else.
-
Hey Rustaceans! Got a question? Ask here (3/2023)!
Poem: More rigid and less popular and aims to be easier https://github.com/poem-web/poem
-
A taste of pavex, an upcoming Rust web framework
Did you check out Poem? It seems promising, with openapi generation built in already.
axum
-
Step-by-Step Guide to Server-Side Render React with Rust
For this example, we will use axum, a web framework that works on top of tokio.
-
How to Deploy Your Rig App on AWS Lambda: A Step-by-Step Guide
If your lambda handles multiple endpoints of your API, the crate axum facilitates the routing within the lambda.
-
Using Polars in Rust for high-performance data analysis
We’ll use Axum with Tokio to build a web backend, Tracing for logging, and Serde for serialization and deserialization.
-
Replacing Nginx with Axum
After I read a bit about axum [1], it says it's a relatively thin wrapper on top of hyper [2], a fast and correct HTTP library.
In other words, what can be done with NGINX, it can be achieved with axum (assuming you know Rust).
It looks interesting, I'm not going to lie!
[1] https://github.com/tokio-rs/axum
[2] https://crates.io/crates/hyper
-
Declarative macro magic from Axum in Rust
If you are familiar with API development in Rust, you may recognize this syntax from Axum. This puzzling question piqued my curiosity and led me to build Cairo, where I re-implemented some key Axum concepts in a simpler way as a learning exercise. I’ve long been fascinated by the intermediate + advanced concepts library authors employ to make their interfaces feel frictionless. Rust sits in a brilliant space because of the way it melds high-level expressiveness with low-level control and performance. One of the ways it accomplishes this is using macros.
-
Axum/Tera & Real Shortcodes in Rust: A WordPress-Like Implementation
Let's create a small prototype in Rust to demonstrate the concept using Tera and Axum.
-
Bundle frontend into axum binary using include_dir
There are some proposals on how to do it already such as https://github.com/tokio-rs/axum/issues/1698.
-
Prodzilla: From Zero to Prod with Rust and Shuttle
Moreover, I especially like where Rust is right now in the web space. It really feels like there’s a lot of smart people working on the next generation of web development tools - it feels like the place to be. There are a range of great open-source web dev tools that are just reaching critical levels of maturity. Axum, which I used to build Prodzilla, feels ready for out of the box web dev, and is crazy-performant, as I write about later. More recently available is Loco, a Rails-like framework for building web applications in Rust that's picking up steam. And in dev-tooling and hosting there’s Shuttle, a 1-line hosting solution for Rust backends.
-
CryptoFlow: Building a secure and scalable system with Axum and SvelteKit - Part 1
CryptoFlow is a full-stack web application built with Axum and SvelteKit. It's a Q&A system tailored towards the world of cryptocurrency!
-
Cryptoflow: Building a secure and scalable system with Axum and SvelteKit - Part 0
You also get to specify the accepted HTTP method of the URL via axum::routing. To answer its name, modularity, Axum also supports nested routes as we'll see later in this series. Next is the layer, a method used to apply tower::Layer to all routes before it. This means that routes added after the layer method will not have such a layer applied to their requests. In our case, we used the layer to add tracing to all HTTP requests and responses to our routes. This is needed for proper logging. The tower_http::trace::TraceLayer can even be really customised.
What are some alternatives?
Rocket - A web framework for Rust.
actix-web - Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
jelly-actix-web-starter - A starter template for actix-web projects that feels very Django-esque. Avoid the boring stuff and move faster.
async-graphql - A GraphQL server library implemented in Rust
warp - A super-easy, composable, web server framework for warp speeds.
okapi - OpenAPI (AKA Swagger) document generation for Rust projects
ntex - framework for composable networking services
rust-web-framework-comparison - A comparison of some web frameworks and libs written in Rust
salvo - A powerful web framework built with a simplified design.
rust-web-benchmarks - Benchmarking web frameworks written in rust with rewrk tool.