4 Commits

Author SHA1 Message Date
idk
921c0f7cef update go modules 2019-10-13 18:54:50 -04:00
idk
14b861da99 be less insistent about index.tengo 2019-10-13 15:51:22 -04:00
idk
2c879fcff9 add missing import 2019-10-13 15:48:33 -04:00
idk
157ace32bd If no index is found, try a readme. If an index.tengo file exists, use that. 2019-10-13 15:39:23 -04:00
3 changed files with 24 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ echo:
USER_GH=eyedeekay
packagename=eephttpd
VERSION=0.0.1
VERSION=0.0.4
tag:
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "I2P Tunnel Management tool for Go applications"

View File

@@ -44,7 +44,7 @@ func (f *EepHttpd) Serve() error {
}
func (f *EepHttpd) Up() bool {
return f.up
return f.up
}
//Close shuts the whole thing down.
@@ -84,7 +84,7 @@ func NewEepHttpdFromOptions(opts ...func(*EepHttpd) error) (*EepHttpd, error) {
}
s.SAMForwarder.Config().SaveFile = true
l, e := s.Load()
//log.Println("Options loaded", s.Print())
//log.Println("Options loaded", s.Print())
if e != nil {
return nil, e
}

View File

@@ -5,6 +5,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
@@ -23,11 +24,31 @@ func (f *EepHttpd) ServeHTTP(rw http.ResponseWriter, rq *http.Request) {
f.HandleFile(rw, rq)
}
func FileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
if info != nil {
return !info.IsDir()
}
return false
}
func (f *EepHttpd) checkURL(rq *http.Request) string {
p := rq.URL.Path
if rq.URL.Path == "/" {
p = "/index.html"
}
if !FileExists(filepath.Join(f.ServeDir, p)) {
p = "/README.md"
}
if !FileExists(filepath.Join(f.ServeDir, p)) {
if FileExists(filepath.Join(f.ServeDir, "/index.tengo")) {
p = "/index.tengo"
}
}
log.Println(p)
return filepath.Join(f.ServeDir, p)
}