filebrowser/cmd/filemanager/main.go

32 lines
516 B
Go
Raw Normal View History

2017-06-25 08:11:25 +00:00
package main
import (
"log"
"net/http"
"github.com/hacdias/filemanager"
)
var m *filemanager.FileManager
func handler(w http.ResponseWriter, r *http.Request) {
2017-06-28 15:05:30 +00:00
// TODO: review return codes and return 0 when everything works.
code, err := m.ServeHTTP(w, r)
2017-06-25 08:11:25 +00:00
if err != nil {
log.Print(err)
}
2017-06-28 15:05:30 +00:00
if code != 0 {
w.WriteHeader(code)
}
2017-06-25 08:11:25 +00:00
}
func main() {
2017-06-25 12:09:49 +00:00
m = filemanager.New("D:\\TEST")
2017-06-27 09:31:50 +00:00
m.SetBaseURL("/vaca")
2017-06-28 10:45:41 +00:00
m.Commands = []string{"git"}
2017-06-25 08:11:25 +00:00
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
2017-06-25 09:02:16 +00:00
}