diff --git a/cmd/test/main.go b/cmd/test/main.go index 785f1e8..b8932b7 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -23,6 +23,9 @@ Def( c.W.Write([]byte("Привет, Мир!")) }), ), +).Def( + "web", + bond.Static("./static"), ) func main() { diff --git a/handler.go b/handler.go index 1c54872..e124cbf 100644 --- a/handler.go +++ b/handler.go @@ -23,3 +23,6 @@ func (fn ContextFunc) ServeHTTP(w ResponseWriter, r *Request) { }) } +func Static(pth string) Handler { + return http.FileServer(http.Dir(pth)) +} diff --git a/router.go b/router.go index 2d2c7f9..6fd1fed 100644 --- a/router.go +++ b/router.go @@ -3,7 +3,7 @@ package bond import ( "net/http" "strings" - "fmt" + //"fmt" "path" ) @@ -42,8 +42,8 @@ func (router *Router) ServeHTTP(w ResponseWriter, r *Request) { prefix = path.Clean("/" + name) } - fmt.Printf("Path: %q\n", r.URL.Path) - fmt.Printf("%q %q %q %q\n", pth, prefix, pths, name) + //fmt.Printf("Path: %q\n", r.URL.Path) + //fmt.Printf("%q %q %q %q\n", pth, prefix, pths, name) handler, ok := router.pathMap[name] if !ok { http.NotFound(w, r) diff --git a/static/file.html b/static/file.html new file mode 100644 index 0000000..b37767d --- /dev/null +++ b/static/file.html @@ -0,0 +1,5 @@ + + + + THE STATIC FILE +