mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-14 05:52:53 +00:00
Create utils.rs for Utilities
This commit is contained in:
parent
4350d5b7b3
commit
2c06ae1d8f
8 changed files with 90 additions and 101 deletions
|
@ -5,12 +5,13 @@ use serde::Deserialize;
|
|||
|
||||
#[path = "subreddit.rs"]
|
||||
mod subreddit;
|
||||
use subreddit::{posts, Post};
|
||||
|
||||
// STRUCTS
|
||||
#[derive(Template)]
|
||||
#[template(path = "popular.html", escape = "none")]
|
||||
struct PopularTemplate {
|
||||
posts: Vec<subreddit::Post>,
|
||||
posts: Vec<Post>,
|
||||
sort: String,
|
||||
}
|
||||
|
||||
|
@ -21,7 +22,7 @@ pub struct Params {
|
|||
|
||||
// RENDER
|
||||
async fn render(sub_name: String, sort: String) -> Result<HttpResponse> {
|
||||
let posts: Vec<subreddit::Post> = subreddit::posts(sub_name, &sort).await;
|
||||
let posts: Vec<Post> = posts(sub_name, &sort).await;
|
||||
|
||||
let s = PopularTemplate { posts: posts, sort: sort }.render().unwrap();
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(s))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue