An open API service indexing awesome lists of open source software.

https://github.com/tobymurray/hmac-predicate

Tower predicate HMAC verification of query params
https://github.com/tobymurray/hmac-predicate

Last synced: about 2 months ago
JSON representation

Tower predicate HMAC verification of query params

Awesome Lists containing this project

README

        

Use something like:

```
use axum::error_handling::HandleErrorLayer;
use axum::Router;
use hmac_predicate::HmacQueryParamValidator;
use reqwest::StatusCode;
use tower::{BoxError, ServiceBuilder};

#[tokio::main]
async fn main() {
let predicate: HmacQueryParamValidator = HmacQueryParamValidator {
key: API_SECRET.to_string(),
};

let builder = ServiceBuilder::new()
.layer(HandleErrorLayer::new(handle_error))
.filter(predicate);

let app = Router::new()
.route("/", get(handler))
.layer(builder);
}

async fn handle_error(err: BoxError) -> (StatusCode, String) {
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Unhandled internal error: {}", err),
)
}
```