save
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user