spring-axum-macros 0.1.0

Procedural macros for spring-axum: auto discovery, controllers, components, interceptors, transactions, caching, events, and SQL/Mapper.
Documentation

spring-axum-macros

spring-axum 的过程宏集合:包括自动发现、控制器、组件、拦截器、事务、缓存、事件、以及 SQL/Mapper 等宏。

示例

use spring_axum_macros::{controller, route, component, interceptor, transaction, cacheable, event, sql, mapper};

#[controller]
struct UserController;

#[route(GET, "/users/:id")]
async fn get_user(id: i64) -> String { format!("{}", id) }

#[component]
struct MyService;

#[interceptor]
impl MyInterceptor {
    async fn on_request(&self, req: axum::extract::Request) -> axum::extract::Request { req }
    async fn on_response(&self, res: axum::response::Response) -> axum::response::Response { res }
}

#[mapper]
impl UserMapper {
    #[sql("SELECT * FROM users WHERE id = #{id}")]
    async fn find_by_id(&self, id: i64) -> anyhow::Result<User> { todo!() }
}

详细用法与注意事项请参考顶层 README.md

许可证

MIT