liweilijie / strangers

to create something record info for stranger use tokio axum web.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

陌生人

物资入库出库清单。利用 tokio,axum 来实现。

  • 后台登录页面。
  • 登录鉴权功能。
  • 展示所有物资。
  • 利用上传文件的方式添加物资入库。
  • 手动添加物资入库。
  • 删除过期物资。

error的处理

这里面的错误处理让我学到很多,没有用到thiserror这个库,但是却很好的定义了各种错误类型,很是方便是自由.

config库

config库也很方便,还有如何读取数组的值这个问题还没有想好,不过也可以作为字符串返回再自己解板,但是这种方式处理始终不安逸.

postgres需要支持数据库的DateTime类型解码

timestamp在postgrespostgres目录下的Cargo.toml中找到了支持的features

[features]
with-bit-vec-0_6 = ["tokio-postgres/with-bit-vec-0_6"]
with-chrono-0_4 = ["tokio-postgres/with-chrono-0_4"]
with-eui48-0_4 = ["tokio-postgres/with-eui48-0_4"]
with-geo-types-0_4 = ["tokio-postgres/with-geo-types-0_4"]
with-serde_json-1 = ["tokio-postgres/with-serde_json-1"]
with-uuid-0_8 = ["tokio-postgres/with-uuid-0_8"]
[badges.circle-ci]
repository = "sfackler/rust-postgres"

所以在我们项目中需要增加对chrono时间解析的features:

tokio-postgres = {version = "0.7", features = ["with-chrono-0_4"] }

postgres的pgadmin

http://222.213.23.231:5050/browser/#

之前的代码有一个bug,当cookie有多个的时候在HeadeersMap之中读不完全,所以引用了另外一个友好处理cookie的库.

tower-cookies = "0.5.1"

postgres手动备份与恢复

# 先备份
docker exec -u root -it postgres /bin/bash
pg_dump -h localhost -p 5432 -U postgres -d dev_strangers -f /export_bak_stranger_2022_03_31.sql

# 恢复到另外一张表
psql -d dev_strangers -U postgres -h localhost -p 5432 -f /export_bak_stranger_2022_03_31.sql

# 当然可以将文件 cp 出来
docker cp postgres:/export_bak_stranger_2022_03_31.sql .

参考的项目

About

to create something record info for stranger use tokio axum web.


Languages

Language:JavaScript 59.1%Language:CSS 15.8%Language:Rust 13.4%Language:HTML 11.5%Language:Shell 0.1%Language:Makefile 0.1%