diff options
Diffstat (limited to 'src/edit/main.go')
-rw-r--r-- | src/edit/main.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/edit/main.go b/src/edit/main.go new file mode 100644 index 0000000..2a640d0 --- /dev/null +++ b/src/edit/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "net/http" + "util" + "os" +) + +func ServeIndex(out http.ResponseWriter, in *http.Request) { + if in.URL.Path != "/" { + http.NotFound(out, in) + } + http.Redirect(out, in, "/files/", http.StatusMovedPermanently) +} + +func main() { + socket, err := util.StreamListener(os.Args[1], os.Args[2]) + errcheck(err) + errcheck(os.Chdir("/srv/http/edit.team4272.com/www.git")) + http.Handle("/", util.SaneHTTPHandler{http.HandlerFunc(ServeIndex)}) + http.Handle("/static/", util.SaneHTTPHandler{http.FileServer(http.Dir("static"))}) + http.Handle("/files/", util.SaneHTTPHandler{http.StripPrefix("/files", http.HandlerFunc(ServeGit))}) + errcheck(http.Serve(socket, nil)) +} |