Fixed Sorting

This commit is contained in:
spikecodes 2020-11-17 16:03:28 -08:00
parent 2c06ae1d8f
commit 05ea0fe1fd
10 changed files with 49 additions and 48 deletions

View file

@ -5,7 +5,7 @@ use chrono::{TimeZone, Utc};
#[path = "utils.rs"]
mod utils;
use utils::{Flair, Post, User, val, nested_val};
use utils::{Params, Flair, Post, User, val, nested_val};
// STRUCTS
#[derive(Template)]
@ -26,13 +26,11 @@ async fn render(username: String, sort: String) -> Result<HttpResponse> {
// SERVICES
#[get("/u/{username}")]
async fn page(web::Path(username): web::Path<String>) -> Result<HttpResponse> {
render(username, "hot".to_string()).await
}
#[get("/u/{username}/{sort}")]
async fn sorted(web::Path((username, sort)): web::Path<(String, String)>) -> Result<HttpResponse> {
render(username, sort).await
async fn page(web::Path(username): web::Path<String>, params: web::Query<Params>) -> Result<HttpResponse> {
match &params.sort {
Some(sort) => render(username, sort.to_string()).await,
None => render(username, "hot".to_string()).await,
}
}
// USER