add rewriting

This commit is contained in:
abbie 2022-03-12 22:08:58 +00:00
parent 2dd59bed81
commit f9894e18f6
No known key found for this signature in database
GPG key ID: 04DDE463F9200F87
3 changed files with 6 additions and 2 deletions

2
Cargo.lock generated
View file

@ -218,7 +218,7 @@ dependencies = [
[[package]]
name = "starfig"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"native-tls",
"packeteer",

View file

@ -1,6 +1,6 @@
[package]
name = "starfig"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,6 +4,7 @@ use std::io::{BufRead, BufReader, Write};
use std::net::{TcpListener, TcpStream};
use std::string::{String};
use std::io::{Read};
use std::path::Path;
use std::sync::Arc;
use std::fs::File;
use std::fs;
@ -22,6 +23,9 @@ fn load_page(segments: Vec<String>) -> String {
for v in segments {
m = format!("{}/{}", m, v);
}
if Path::new(&m).is_dir() == true {
m = format!("{}/index.gmi", m);
}
let page = fs::read_to_string(m);
match page {
Ok(i) => i.to_string(),