32 个稳定版本
1.3.0 | 2024年6月3日 |
---|---|
1.2.1 | 2024年5月15日 |
1.2.0 | 2024年4月23日 |
1.1.28 | 2024年3月30日 |
0.1.0 | 2024年1月28日 |
#190 在 HTTP 服务器
每月下载量 170 次
1MB
24K SLoC
⭐️ rust doc https://doc.rust-lang.net.cn/
⭐️ macos 安装 cmake 以编译 kafka
$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/usr/local/bin
⭐️ GStreamer 二进制文件
$ 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.cn/
⭐️ 检查 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
⭐️ 检查 sqlx 版本
$ sqlx --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
⭐️ 复制 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
> }
依赖项
~172MB
~3M SLoC