| Crates.io | hessra-macros |
| lib.rs | hessra-macros |
| version | 0.1.0 |
| created_at | 2025-02-25 02:16:08.227191+00 |
| updated_at | 2025-02-25 02:16:08.227191+00 |
| description | Hessra authorization service macros for Rust |
| homepage | |
| repository | https://github.com/Hessra-Labs/hessra-sdk.rs |
| max_upload_size | |
| id | 1568627 |
| size | 41,532 |
Procedural macros for the Hessra authorization service SDK for Rust.
This crate provides procedural macros that simplify working with the Hessra authorization service. It is part of the hessra-sdk ecosystem.
request_authorizationThe request_authorization macro wraps a function with authorization token request logic. It will request an authorization token for a given resource before executing the wrapped function.
use hessra_macros::request_authorization;
// With client config parameter
#[request_authorization("my-resource", client_config)]
async fn protected_function(client_config: HessraConfig) {
// This function will be called after token is obtained
}
// Using global configuration
#[request_authorization("my-resource")]
async fn protected_function_global() {
// This function will be called after token is obtained
}
authorizeThe authorize macro validates that a token parameter is present in the function signature and can be used for authorization checks.
use hessra_macros::authorize;
#[authorize("my-resource")]
async fn protected_function(token: &str) {
// This function will be called if the token is valid
}
axum - Enables integration with the Axum web frameworkThis project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.