add rewriting
This commit is contained in:
parent
2dd59bed81
commit
f9894e18f6
3 changed files with 6 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -218,7 +218,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "starfig"
|
name = "starfig"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"packeteer",
|
"packeteer",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "starfig"
|
name = "starfig"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::io::{BufRead, BufReader, Write};
|
||||||
use std::net::{TcpListener, TcpStream};
|
use std::net::{TcpListener, TcpStream};
|
||||||
use std::string::{String};
|
use std::string::{String};
|
||||||
use std::io::{Read};
|
use std::io::{Read};
|
||||||
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
@ -22,6 +23,9 @@ fn load_page(segments: Vec<String>) -> String {
|
||||||
for v in segments {
|
for v in segments {
|
||||||
m = format!("{}/{}", m, v);
|
m = format!("{}/{}", m, v);
|
||||||
}
|
}
|
||||||
|
if Path::new(&m).is_dir() == true {
|
||||||
|
m = format!("{}/index.gmi", m);
|
||||||
|
}
|
||||||
let page = fs::read_to_string(m);
|
let page = fs::read_to_string(m);
|
||||||
match page {
|
match page {
|
||||||
Ok(i) => i.to_string(),
|
Ok(i) => i.to_string(),
|
||||||
|
|
Loading…
Reference in a new issue