ntfy-api
This library contains async rust bindings for the ntfy API.
It uses reqwest as HTTP client.
Features implemented:
Usage
Cargo.toml:
[dependencies]
tokio = { version = "1", features = ["full"] }
ntfy-api = "^0.1.1"
use ntfy_api::{NtfyApi, NtfyMsg};
#[tokio::main]
async fn main() {
let api = NtfyApi::default();
let ntfy_msg = NtfyMsg {
topic: String::from("alerts"),
message: Some(String::from("Message body")),
title: Some(String::from("New Message")),
tags: None,
priority: None,
attach: None,
filename: None,
click: None,
action: None,
};
match api.post(&ntfy_msg).await {
Ok(_) => println!("Message sent"),
Err(_) => println!("Error sending message"),
}
}
Configuration
let api = NtfyApi::new(NtfySettings {
host: String::from("https://ntfysh/"),
authorization: Some(NtfyAuthorization {
username: String::from("username"),
password: String::from("password"),
}),
});