Comments (1)
To see the clear difference in a concrete example (of get_current_user
handler), basically, this means:
- Instead of having defined
UserOutDTO
and itsUserOutDTOUserAttrs
child, and respond like this:let out = UserOutDTO { user: UserOutDTOUserAttrs { email: entry.user.email, token: None, username: entry.user.username, bio: entry.user.bio, image: entry.user.image, }, }; (StatusCode::OK, Json(serde_json::to_value(out).unwrap()))
- There is just one
UserOutDTO
, and the response looks like this:and thatrespond_with_user_dto( email, token, username, bio, image, ),
respond_with_user_dto
function includes:let dto = UserOutDTO { email, token, username, bio, image, }; (StatusCode::OK, Json(json!({ "user": dto })))
💡 Idea: Another approach is to have the User
and UserEntry
structs to implement Axum's IntoResponse
trait, and thus only the instances of these structs could be returned and the rest is Axum's logic.
from fullstack-rust-axum-dioxus-rwa.
Related Issues (20)
- Include user's email in the token, and add an extractor of it
- `sqlx::FromFrow` as implementation vs attribute HOT 1
- Respond with a JSON in case of initial request body deserialization issues HOT 1
- [backend] Graceful Shutdown
- Better handling of article slug uniqueness
- Follow User that doesn't exist
- [be] `ArticlesRepo` - Refactor the common parts
- [be] `ArticlesRepo` - Fix delete article with tags HOT 1
- [be] Fix handling of creating an article with same slug
- [be] Consistenly use `UserId` extractor, instead of `Claims`
- [be] Only owned articles can be updated or deleted
- [be] A user cannot follow himself
- AppError - `AuthInvalidTokenErr` to be covered by `AuthUnauthorized`
- API Routes grouping HOT 1
- Integration Testing
- Current source code doesn't compile correctly HOT 3
- [front-end] Deep link support (or just a routing issue) HOT 1
- [back-end cli] Gracefully restart on code changes HOT 1
- [front-end] Upgrade to Dioxus 0.5
- Swagger documentation HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fullstack-rust-axum-dioxus-rwa.