Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
921c0f7cef | ||
![]() |
14b861da99 | ||
![]() |
2c879fcff9 | ||
![]() |
157ace32bd |
2
Makefile
2
Makefile
@@ -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"
|
||||
|
@@ -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
|
||||
}
|
||||
|
21
serve.go
21
serve.go
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user