1package main 2 3import ( 4 "github.com/cyrus-and/gdb/web" 5 "log" 6 "net/http" 7 "path/filepath" 8) 9 10func main() { 11 mux, err := web.NewHandler() 12 if err != nil { 13 log.Fatal(err) 14 } 15 // static assets 16 mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { 17 http.ServeFile(w, req, filepath.Join("static", req.URL.Path[1:])) 18 }) 19 // source files 20 mux.HandleFunc("/source/", func(w http.ResponseWriter, req *http.Request) { 21 http.ServeFile(w, req, req.URL.Path[len("/source"):]) 22 }) 23 log.Fatal(http.ListenAndServe("localhost:8080", mux)) 24} 25