Moved away from local files to complete database driven articles

This commit is contained in:
2021-12-20 23:10:04 +01:00
parent bc3ec64b3c
commit c909339a73
20 changed files with 302 additions and 299 deletions

17
server/path.go Normal file
View File

@@ -0,0 +1,17 @@
package server
import (
"TheAdversary/config"
"net/http"
"os"
"path/filepath"
)
func ServePath(w http.ResponseWriter, r *http.Request) {
path := filepath.Join(config.FrontendDir, r.URL.Path)
if _, err := os.Stat(path); os.IsNotExist(err) {
Error404(w, r)
} else {
http.ServeFile(w, r, path)
}
}