mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-15 14:32:50 +00:00
Clean-up and more consistent styles.
This commit is contained in:
parent
c71df35b22
commit
11e4ff42ed
6 changed files with 32 additions and 18 deletions
|
@ -100,8 +100,7 @@ async fn main() -> std::io::Result<()> {
|
|||
.route("/", web::get().to(subreddit::page))
|
||||
.route("/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
|
||||
// Handle subscribe/unsubscribe
|
||||
.route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::set))
|
||||
//.route("/unsubscribe/", web::post().to(subreddit::unsubscribe))
|
||||
.route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::subscriptions))
|
||||
// View post on subreddit
|
||||
.service(
|
||||
web::scope("/comments/{id}/{title}")
|
||||
|
|
|
@ -65,7 +65,7 @@ pub async fn page(req: HttpRequest) -> HttpResponse {
|
|||
}
|
||||
|
||||
// Sub or unsub by setting subscription cookie using response "Set-Cookie" header
|
||||
pub async fn set(req: HttpRequest) -> HttpResponse {
|
||||
pub async fn subscriptions(req: HttpRequest) -> HttpResponse {
|
||||
let mut res = HttpResponse::Found();
|
||||
let default = cookie(&req, "front_page");
|
||||
let sub = req
|
||||
|
|
|
@ -145,7 +145,7 @@ pub fn prefs(req: HttpRequest) -> Preferences {
|
|||
wide: cookie(&req, "wide"),
|
||||
hide_nsfw: cookie(&req, "hide_nsfw"),
|
||||
comment_sort: cookie(&req, "comment_sort"),
|
||||
subs: cookie(&req, "subscriptions").split(",").map(|s| s.to_string()).filter(|s| s != "").collect(),
|
||||
subs: cookie(&req, "subscriptions").split(",").map(String::from).filter(|s| s != "").collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue