2017-06-25 16:11:25 +08: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 23:05:30 +08:00
|
|
|
// TODO: review return codes and return 0 when everything works.
|
|
|
|
|
|
|
|
code, err := m.ServeHTTP(w, r)
|
2017-06-25 16:11:25 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
2017-06-28 23:05:30 +08:00
|
|
|
|
|
|
|
if code != 0 {
|
|
|
|
w.WriteHeader(code)
|
|
|
|
}
|
2017-06-25 16:11:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2017-06-25 20:09:49 +08:00
|
|
|
m = filemanager.New("D:\\TEST")
|
2017-06-27 17:31:50 +08:00
|
|
|
m.SetBaseURL("/vaca")
|
2017-06-28 18:45:41 +08:00
|
|
|
m.Commands = []string{"git"}
|
2017-06-25 16:11:25 +08:00
|
|
|
http.HandleFunc("/", handler)
|
2017-06-30 00:54:57 +08:00
|
|
|
http.ListenAndServe(":80", nil)
|
2017-06-25 17:02:16 +08:00
|
|
|
}
|