Rust warp version of crud

Rust is a hard language to understand. The key is the lack of documentation, and while the library is rich, the tutorial cases can be either simple or hard to understand. All kinds of Googles, all kinds of Bing. Finally, I have to try all kinds of bricks. There are times when you struggle with a single line of code. In line with the thinking of serving the people, share the results of recent tampering, and slightly optimize the brick-moving experience of rust newcomers.

A cruel man seldom speaks

On the first code

Github.com/wesin/harry…

Warp version of web server

Why warp. Just because the use cases of warp are easier to read, which Axum case documents are less, writing code by guessing is so damn hard.

Postgresql used by the database

Use it and you’re done

Sea-orm writes code without SQL

Increase the experience of moving bricks, writing SQL undoubtedly increases the amount of code, and prone to error. Simple function simple realization, how fast how to.

Knowledge point of this project (carrying bricks)

  • Once_cell singleton usage involves the data connection pool object DB_Center and program configuration object config
  • Log4rs configuration and usage
  • Thiserror unified error handling encapsulation and usage
  • Config Indicates the use of project configuration
  • Warp web framework
  • Sea-orm ORM database framework
  • Sea-orm – CLI Run the build.bat of the project to automatically generate database operation classes corresponding to SEA-ORm.
  • File upload and Download
  • Use of question marks in warp CRUd code to simplify match error handling code

How to play

  1. Download the project
  2. The resource folder contains database build table SQL
cargo run
Copy the code
  1. There are also interface tests for postman exports in resource

see you