mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-07 23:27:51 +00:00
Rewrite + Searching
This commit is contained in:
parent
c7282520cd
commit
a6dc7ee043
17 changed files with 342 additions and 262 deletions
20
src/main.rs
20
src/main.rs
|
@ -2,9 +2,9 @@
|
|||
use actix_web::{get, middleware::NormalizePath, web, App, HttpResponse, HttpServer};
|
||||
|
||||
// Reference local files
|
||||
mod popular;
|
||||
mod post;
|
||||
mod proxy;
|
||||
mod search;
|
||||
mod subreddit;
|
||||
mod user;
|
||||
mod utils;
|
||||
|
@ -42,6 +42,7 @@ async fn main() -> std::io::Result<()> {
|
|||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
// .default_service(web::get().to(subreddit::page))
|
||||
// TRAILING SLASH MIDDLEWARE
|
||||
.wrap(NormalizePath::default())
|
||||
// GENERAL SERVICES
|
||||
|
@ -50,17 +51,22 @@ async fn main() -> std::io::Result<()> {
|
|||
.route("/robots.txt/", web::get().to(robots))
|
||||
// PROXY SERVICE
|
||||
.route("/proxy/{url:.*}/", web::get().to(proxy::handler))
|
||||
// SEARCH SERVICES
|
||||
.route("/search/", web::get().to(search::page))
|
||||
.route("r/{sub}/search/", web::get().to(search::page))
|
||||
// USER SERVICES
|
||||
.route("/u/{username}/", web::get().to(user::page))
|
||||
.route("/user/{username}/", web::get().to(user::page))
|
||||
.route("/u/{username}/", web::get().to(user::profile))
|
||||
.route("/user/{username}/", web::get().to(user::profile))
|
||||
// SUBREDDIT SERVICES
|
||||
.route("/r/{sub}/", web::get().to(subreddit::page))
|
||||
.route("/r/{sub}/{sort}/", web::get().to(subreddit::page))
|
||||
// POPULAR SERVICES
|
||||
.route("/", web::get().to(popular::page))
|
||||
.route("/", web::get().to(subreddit::page))
|
||||
.route("/{sort:best|hot|new|top|rising}/", web::get().to(subreddit::page))
|
||||
// POST SERVICES
|
||||
.route("/{id:.{5,6}}/", web::get().to(post::short))
|
||||
.route("/r/{sub}/comments/{id}/{title}/", web::get().to(post::page))
|
||||
.route("/r/{sub}/comments/{id}/{title}/{comment_id}/", web::get().to(post::comment))
|
||||
.route("/{id:.{5,6}}/", web::get().to(post::item))
|
||||
.route("/r/{sub}/comments/{id}/{title}/", web::get().to(post::item))
|
||||
.route("/r/{sub}/comments/{id}/{title}/{comment_id}/", web::get().to(post::item))
|
||||
})
|
||||
.bind(address.clone())
|
||||
.expect(format!("Cannot bind to the address: {}", address).as_str())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue