mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-04 20:30:37 +00:00
Actix Rewrite
This commit is contained in:
commit
9bd1b247bd
14 changed files with 3599 additions and 0 deletions
49
src/main.rs
Normal file
49
src/main.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Import Crates
|
||||
extern crate comrak;
|
||||
use actix_files::NamedFile;
|
||||
use actix_web::{get, App, HttpServer, HttpResponse, Result};
|
||||
|
||||
// Reference local files
|
||||
mod user;
|
||||
mod popular;
|
||||
mod post;
|
||||
mod subreddit;
|
||||
|
||||
// Create Services
|
||||
#[get("/style.css")]
|
||||
async fn style() -> Result<NamedFile> {
|
||||
let file = NamedFile::open("static/style.css");
|
||||
Ok(file?)
|
||||
}
|
||||
|
||||
#[get("/favicon.ico")]
|
||||
async fn favicon() -> HttpResponse {
|
||||
HttpResponse::Ok().body("")
|
||||
}
|
||||
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
// start http server
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
// GENERAL SERVICES
|
||||
.service(style)
|
||||
.service(favicon)
|
||||
// POST SERVICES
|
||||
.service(post::short)
|
||||
.service(post::page)
|
||||
.service(post::sorted)
|
||||
// SUBREDDIT SERVICES
|
||||
.service(subreddit::page)
|
||||
.service(subreddit::sorted)
|
||||
// POPULAR SERVICES
|
||||
.service(popular::page)
|
||||
// .service(popular::sorted)
|
||||
// USER SERVICES
|
||||
.service(user::page)
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue