This commit is contained in:
2026-02-24 15:59:26 -05:00
parent ebd14a1b36
commit 1dd76cf1d2
24 changed files with 338 additions and 227 deletions

View File

@@ -1,8 +1,9 @@
package server
import (
"errors"
"fmt"
"net/http"
"io"
"os"
"path"
"path/filepath"
@@ -95,15 +96,22 @@ func generateArchiveIndex(fsPath string, urlPath string) (string, error) {
}
/* helper to read the archive files */
func readArchive(w http.ResponseWriter, route string) error {
fsPath := "." + route
if info, err := os.Stat(fsPath); err == nil && info.IsDir() {
if page, err := generateArchiveIndex(fsPath, route); err == nil {
w.Write([]byte(page))
return nil
} else {
return err
func readArchive(w io.Writer, route string, protcol Protocols) error {
switch protcol {
case HTTP:
fsPath := "." + route
if info, err := os.Stat(fsPath); err == nil && info.IsDir() {
if page, err := generateArchiveIndex(fsPath, route); err == nil {
w.Write([]byte(page))
return nil
} else {
return err
}
}
case GEMINI:
panic(errors.New("TODO"))
default:
panic(errors.New("Invalid Protocol"))
}
return nil
}