~/selfhut

selfhut/src/main.rs -rw-r--r-- 800 B
7dbdfabf — arthurmelton I did alot, I should have commited more 2 years ago

            
19f9b68c arthurmelton
ad9e5164 arthurmelton
00c0a257 Arthur Melton
0545f2a7 Arthur Melton
ef55c0da arthurmelton
0545f2a7 Arthur Melton
94e2262d arthurmelton
532ca616 Arthur Melton
616316d3 Arthur Melton
47885f67 Arthur Melton
f2f2d97d Arthur Melton
01f10fe8 Arthur Melton
76d4fa6d Arthur Melton
00c0a257 Arthur Melton
e4d868e2 Arthur Melton
ef55c0da arthurmelton
7dbdfabf arthurmelton
7dbdfabf arthurmelton
00c0a257 Arthur Melton
0545f2a7 Arthur Melton
00c0a257 Arthur Melton
66cb4022 Arthur Melton
80cce623 Arthur Melton
00c0a257 Arthur Melton
76d4fa6d Arthur Melton
1268e21e Arthur Melton
69345aa0 Arthur Melton
b1605a54 Arthur Melton
b961c5bf Arthur Melton
00c0a257 Arthur Melton
0545f2a7 Arthur Melton
6c6e1160 Arthur Melton
7dbdfabf arthurmelton
66cb4022 Arthur Melton
7dbdfabf arthurmelton
80cce623 Arthur Melton
5c44f94c Arthur Melton
19f9b68c arthurmelton
80cce623 Arthur Melton

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#[macro_use]
extern crate rocket;
mod git;
mod index;
mod repository;
mod utils;
mod clone;

use utils::config;

use rocket::fs::relative;
use rocket::fs::FileServer;
use rocket_dyn_templates::Template;
use crate::repository::summary;
use crate::repository::tree;
use crate::repository::raw;
use crate::utils::own_pathbuf::PathBufWithDotfiles;

#[launch]
fn rocket() -> _ {
    rocket::build()
        .mount("/", routes![file_server, index::index, summary::repository, tree::tree_main, tree::tree, clone::clone, raw::raw])
        .attach(Template::fairing())
}

#[get("/static/<path..>")]
async fn file_server(path: PathBufWithDotfiles) -> Option<rocket::fs::NamedFile> {
    let path = std::path::Path::new(relative!("static")).join(path.get());
    rocket::fs::NamedFile::open(path).await.ok()
}