-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example App: Small Axum cleanup and module rework
- Loading branch information
1 parent
276e98c
commit 59d3e35
Showing
5 changed files
with
118 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use reqwest::header::{HeaderMap, HeaderName}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct Feed { | ||
pub id: usize, | ||
pub name: String, | ||
pub url: String, | ||
pub frequency: u64, | ||
pub headers: HashMap<String, String>, | ||
} | ||
|
||
impl Feed { | ||
pub fn to_header_map(&self) -> HeaderMap { | ||
let mut headers = HeaderMap::new(); | ||
for (key, value) in self.headers.iter() { | ||
let new_key: HeaderName = key.parse().unwrap(); | ||
headers.insert(new_key, value.parse().unwrap()); | ||
} | ||
headers | ||
} | ||
} | ||
|
||
/// This represents a [`Feed`] but without an ID, which are used in POST bodies. | ||
#[derive(Clone, Deserialize, Serialize)] | ||
pub struct CreateFeed { | ||
pub name: String, | ||
pub url: String, | ||
pub frequency: u64, | ||
pub headers: HashMap<String, String>, | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct Status { | ||
status: String, | ||
} | ||
|
||
impl Status { | ||
pub fn new(status: &str) -> Self { | ||
Self { | ||
status: status.to_string(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters