分享一个 Rust Axum 中封装自用简单的分页查询函数,使用的是 sqlx 查询数据库。 方法 use std::{collections::HashMap, marker::PhantomData}; use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::{ postgres…
跨域 1. 依赖 [dependencies] tower-http = { version = "0.5.2", features = ["cors"] } 2. 配置 在router的最后添加layer(在路由配置的最后才生效) // src/main.rs use tower_http::{ cors:…
使用service部署 1. 创建 Systemd 服务文件 文件名及内容根据自己修改,存放路径为:/etc/systemd/system/myapp.service,内容参考: # /etc/systemd/system/myapp.service [Unit] Description=myapp After=network.target [Se…