zero4rs

Crates.iozero4rs
lib.rszero4rs
version1.3.0
sourcesrc
created_at2024-01-28 01:19:14.110838
updated_at2024-06-03 12:48:57.077539
descriptionzero4rs is a powerful, pragmatic, and extremely fast web framework for Rust
homepagehttps://github.com/chunhui2001/zero4rs
repositoryhttps://github.com/chunhui2001/zero4rs
max_upload_size
id1117218
size1,202,800
Keesh (chunhui2001)

documentation

https://docs.rs/zero4rs

README

⭐️ rust doc https://doc.rust-lang.org/

⭐️ macos 安装 cmake to compile kafka

$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/usr/local/bin

⭐️ GStreamer Binaries

$ gstreamer-1.0-1.20.4-universal.pkg and gstreamer-1.0-devel-1.20.4-universal.pkg
$ export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}"

$ find /opt/homebrew/Cellar  -name gobject-2.0.pc
$ /opt/homebrew/Cellar/glib/2.80.0_2/lib/pkgconfig/gobject-2.0.pc
> export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/homebrew/Cellar/glib/2.80.0_2/lib/pkgconfig

⭐️ 视频处理

$ brew install ffmpeg
$ sudo apt-get install libavutil-dev

⭐️ Homebrew Formulae

https://formulae.brew.sh/

⭐️ check pkg-config

pkg-config --list-all
pkg-config --modversion gobject-2.0

⭐️ 本程序依赖以下 Rust 工具

$ rustup toolchain install nightly --allow-downgrade
$ rustup component add clippy
$ rustup component add rustfmt

$ cargo install cargo-expand
$ cargo install cargo-udeps
$ cargo install cargo-watch
$ cargo install cargo-tarpaulin
$ cargo install watchexec-cli
$ cargo install cargo-tree
$ cargo install cargo-tarpaulin
$ cargo install cargo-bloat

$ cargo install cargo-edit
$ cargo install -f cargo-upgrades

$ cargo install sqlx-cli --no-default-features --features postgres
$ cargo install sqlx-cli --version 0.7.3 --force
$ cargo +nightly expand
$ cargo +nightly udeps

⭐️ check sqlx version

$ sqlx --version

⭐️ get last version

curl -L https://crates.io/api/v1/crates/zero4rs | jq .crate.max_stable_version
curl -L https://crates.io/api/v1/crates/zero4rs/1.1.18/readme

⭐️ 创建项目

$ cargo new <YOUR_PROJECT_NAME_HERE> --bin && cd <YOUR_PROJECT_NAME_HERE>

⭐️ 添加依赖

[dependencies]
log = "0.4.21"
awc = "3.4.0"
zero4rs = "1.1.29"
anyhow = "1.0.81"
lazy_static = "1.4.0"
clap = { version = "3.2.25", features = ["derive", "wrap_help"] }
actix-web = { version = "4.5.1", features = ["openssl"] }
actix-web-validator = "5.0.1"
actix-server = "2.3.0"
actix-request-identifier = "4.1.0"
actix-rt = "2.9.0"
mongodb = { version = "2.8.2", features = ["tokio-runtime"] }
serde = { version = "1.0.197", features = ["derive"] }
validator = { version = "0.16", features = ["derive"] }
struct-merge = "0.1.1"
serde_json = "1.0.115"
tokio = { version = "1.37.0", features = ["full"] }
tokio-stream = "0.1.15"

⭐️ 更新版本

cargo update
cargo upgrade

⭐️ 复制文件

$ mkdir dist
$ cp -rf ../../zero4rs/Makefile ./
$ cp -rf ../../zero4rs/Dockerfile ./
$ cp -rf ../../zero4rs/DockerfileBuild ./
$ cp -rf ../../zero4rs/docker-compose.yml ./
$ cp -rf ../../zero4rs/entrypoint.sh ./
$ cp -rf ../../zero4rs/RichMedias ./
$ cp -rf ../../zero4rs/resources ./
$ cp -rf ../../zero4rs/views ./
$ cp -rf ../../zero4rs/configuration ./
$ cp -rf ../../zero4rs/zero4rs.com+7-key.pem ./<YOUR_PROJECT_NAME_HERE>.com+7-key.pem
$ cp -rf ../../zero4rs/zero4rs.com+7.pem ./<YOUR_PROJECT_NAME_HERE>.com+7.pem
$ cp -rf ../../zero4rs/src/server ./src

⭐️ 替换名字

>> search and replace zero4rs to <YOUR_PROJECT_NAME_HERE> in below files
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' Makefile
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' Dockerfile
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' DockerfileBuild
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' docker-compose.yml
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' entrypoint.sh
sed -i'.bak' -e 's/zero4rs/<YOUR_PROJECT_NAME_HERE>/g' configuration
sed -i'.bak' -e 's/crate/zero4rs/g' ./src/server/*
rm -rf *.bak && rm -rf ./configuration/*.bak && rm -rf ./src/server/*.bak

⭐️ copy main.rs

> // use zero4rs::core::auth0::auth;
> use <YOUR_PROJECT_NAME_HERE>::server::Application;
> use zero4rs::core::auth0::Protected;
> use zero4rs::core::url_dispatch::*;
>
> pub const P0: Protected = Protected::AnonymousUser;
>
> #[rustfmt::skip]
> #[actix_web::main]
> async fn main() {
>     Application::run("<YOUR_PROJECT_NAME_HERE>", |cfg, app_state| {
>         url_dispatch(cfg, app_state.clone(), "get", P0, "/health", || async { "Hello, server is alive and kicking." });
>     })
>     .await
> }
Commit count: 20

cargo fmt