Rewrite URL Dispatch

This commit is contained in:
spikecodes 2020-12-14 16:35:04 -08:00
parent 148d87fb45
commit 75bc170eba
7 changed files with 28 additions and 32 deletions

View file

@ -1,6 +1,6 @@
// CRATES
use crate::utils::{fetch_posts, nested_val, request, ErrorTemplate, Params, Post, User};
use actix_web::{get, http::StatusCode, web, HttpResponse, Result};
use actix_web::{http::StatusCode, web, HttpResponse, Result};
use askama::Template;
// STRUCTS
@ -39,8 +39,7 @@ async fn render(username: String, sort: String) -> Result<HttpResponse> {
}
// SERVICES
#[get("/u/{username}")]
async fn page(web::Path(username): web::Path<String>, params: web::Query<Params>) -> Result<HttpResponse> {
pub 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,