6 Commits

Author SHA1 Message Date
idk
78d3702851 update go modules 2019-10-13 18:59:13 -04:00
idk
5658dab81e update go modules 2019-10-13 18:58:34 -04:00
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
4 changed files with 38 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ echo:
USER_GH=eyedeekay
packagename=eephttpd
VERSION=0.0.1
VERSION=0.0.5
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
}

14
go.mod Normal file
View File

@@ -0,0 +1,14 @@
module github.com/eyedeekay/eephttpd
go 1.12
require (
github.com/d5/tengo v1.24.3
github.com/eyedeekay/sam-forwarder v0.0.0-20190928041036-d2f767dbe008
github.com/eyedeekay/sam3 v0.0.0-20190730185140-f8d54526ea25
gitlab.com/golang-commonmark/html v0.0.0-20180917080848-cfaf75183c4a // indirect
gitlab.com/golang-commonmark/linkify v0.0.0-20180917065525-c22b7bdb1179 // indirect
gitlab.com/golang-commonmark/markdown v0.0.0-20181102083822-772775880e1f
gitlab.com/golang-commonmark/mdurl v0.0.0-20180912090424-e5bce34c34f2 // indirect
gitlab.com/golang-commonmark/puny v0.0.0-20180912090636-2cd490539afe // indirect
)

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)
}