mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
Change file extension from .gemini to .gmi
This commit is contained in:
parent
5314e23415
commit
7899d9addb
2 changed files with 3 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
|
||||||
agate 0.0.0.0:1965 path/to/content/ cert.pem key.rsa
|
agate 0.0.0.0:1965 path/to/content/ cert.pem key.rsa
|
||||||
```
|
```
|
||||||
|
|
||||||
When a client requests the URL `gemini://example.com/foo/bar`, Agate will respond with the file at `path/to/content/foo/bar`. If there is a directory at that path, Agate will look for a file named `index.gemini` inside that directory.
|
When a client requests the URL `gemini://example.com/foo/bar`, Agate will respond with the file at `path/to/content/foo/bar`. If there is a directory at that path, Agate will look for a file named `index.gmi` inside that directory.
|
||||||
|
|
||||||
[Gemini]: https://gemini.circumlunar.space/
|
[Gemini]: https://gemini.circumlunar.space/
|
||||||
[Rust]: https://www.rust-lang.org/
|
[Rust]: https://www.rust-lang.org/
|
||||||
|
|
|
||||||
|
|
@ -125,14 +125,14 @@ async fn send_response<W: Write + Unpin>(url: &Url, mut stream: W) -> Result {
|
||||||
}
|
}
|
||||||
if path.is_dir().await {
|
if path.is_dir().await {
|
||||||
if url.as_str().ends_with('/') {
|
if url.as_str().ends_with('/') {
|
||||||
path.push("index.gemini");
|
path.push("index.gmi");
|
||||||
} else {
|
} else {
|
||||||
return redirect_slash(url, stream).await;
|
return redirect_slash(url, stream).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match async_std::fs::read(&path).await {
|
match async_std::fs::read(&path).await {
|
||||||
Ok(body) => {
|
Ok(body) => {
|
||||||
if path.extension() == Some(OsStr::new("gemini")) {
|
if path.extension() == Some(OsStr::new("gmi")) {
|
||||||
stream.write_all(b"20 text/gemini\r\n").await?;
|
stream.write_all(b"20 text/gemini\r\n").await?;
|
||||||
} else {
|
} else {
|
||||||
let mime = tree_magic::from_u8(&body);
|
let mime = tree_magic::from_u8(&body);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue