feat: reorganize to one flake one rust project
This commit is contained in:
parent
5183130427
commit
e8b60519e7
23 changed files with 792 additions and 2144 deletions
|
|
@ -7,6 +7,7 @@ use axum::extract::State;
|
|||
use axum::http::{HeaderMap, StatusCode};
|
||||
use axum::routing::get;
|
||||
use axum::{Json, Router};
|
||||
use noisebell_common::{validate_bearer, WebhookPayload};
|
||||
use serde::Serialize;
|
||||
use tokio_gpiod::{Bias, Chip, Edge, EdgeDetect, Options};
|
||||
use tracing::{error, info, warn};
|
||||
|
|
@ -21,14 +22,6 @@ struct AppState {
|
|||
inbound_api_key: String,
|
||||
}
|
||||
|
||||
fn validate_bearer(headers: &HeaderMap, expected: &str) -> bool {
|
||||
headers
|
||||
.get("authorization")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.map(|v| v.strip_prefix("Bearer ").unwrap_or("") == expected)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatusResponse {
|
||||
status: &'static str,
|
||||
|
|
@ -324,7 +317,7 @@ async fn main() -> Result<()> {
|
|||
let status = status_str(new_open);
|
||||
info!(status, timestamp, "state changed");
|
||||
|
||||
let payload = serde_json::json!({ "status": status, "timestamp": timestamp });
|
||||
let payload = WebhookPayload { status: status.to_string(), timestamp };
|
||||
|
||||
for attempt in 0..=retry_attempts {
|
||||
let result = client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue