mirror of
https://codeberg.org/icewind/rss-webhook-trigger.git
synced 2026-11-30 04:00:49 +01:00
add option for serving jwt info
This commit is contained in:
parent
766a820f96
commit
c04a04ea29
8 changed files with 256 additions and 22 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -6,19 +6,19 @@ mod jwt;
|
|||
|
||||
use crate::config::{Config, FeedConfig, HeaderVal};
|
||||
use crate::error::{FetchError, FetchFeedError, HubError, ParseFeedError, TriggerError};
|
||||
use crate::fetcher::{next_fetch, CacheHeaders, FetchPlan, FetchResponse};
|
||||
use crate::jwt::generate_token;
|
||||
use crate::fetcher::{CacheHeaders, FetchPlan, FetchResponse, next_fetch};
|
||||
use crate::jwt::{generate_token, serve_well_known};
|
||||
use main_error::MainResult;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::thread::sleep;
|
||||
use std::thread::{sleep, spawn};
|
||||
use std::time::{Duration, Instant};
|
||||
use tracing::{debug, error, info, instrument, warn};
|
||||
use ureq::http::header::{HeaderValue, USER_AGENT};
|
||||
use ureq::http::Response;
|
||||
use ureq::http::header::{HeaderValue, USER_AGENT};
|
||||
use ureq::{Agent, Body};
|
||||
|
||||
const FETCHER_USER_AGENT: &str = concat!(
|
||||
|
|
@ -47,6 +47,20 @@ fn main() -> MainResult {
|
|||
|
||||
let config = Config::from_file(&file)?;
|
||||
|
||||
if let Some(jwt_config) = config.jwt.clone() {
|
||||
if let Some(listen) = jwt_config.listen.clone() {
|
||||
spawn(|| {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_io()
|
||||
.build()
|
||||
.expect("Setup tokio");
|
||||
if let Err(e) = rt.block_on(serve_well_known(jwt_config, listen)) {
|
||||
eprintln!("{e:#}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
info!("Running rss trigger for {} feeds", config.feed.len());
|
||||
|
||||
ctrlc::set_handler(|| RUNNING.store(false, Ordering::SeqCst))?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue