Compare commits

..

1 commit
main ... setup

Author SHA1 Message Date
e1cb00f0b1
Basic fetch channel 2026-01-14 16:12:15 -08:00
4 changed files with 2156 additions and 0 deletions

2120
koucha/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,3 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
axum = "0.8.8"
reqwest = "0.13.1"
rss = "2.0.12"
tokio = { version = "1.49.0", features = ["full"] }

View file

@ -0,0 +1,11 @@
use std::error::Error;
use reqwest::Client;
use koucha::fetch_channel;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client = Client::new();
let _channel = fetch_channel(&client, "https://lorem-rss.herokuapp.com/feed?unit=year").await?;
Ok(())
}

View file

@ -0,0 +1,21 @@
use std::error::Error;
use reqwest::{
IntoUrl,
Client,
};
use rss::Channel as RawChannel;
pub struct Channel {
pub channel: rss::Channel,
}
pub async fn fetch_channel<T: IntoUrl>(
client: &Client, url: T) -> Result<Channel, Box<dyn Error>> {
let content = client.get(url)
.send().await?
.bytes().await?;
let raw_channel = RawChannel::read_from(&content[..])?;
println!("{}", raw_channel.title);
Ok(Channel { channel: raw_channel })
}