Added the static.
This commit is contained in:
parent
e26dee007f
commit
9ca087edc9
4 changed files with 14 additions and 3 deletions
|
@ -23,6 +23,9 @@ Def(
|
||||||
c.W.Write([]byte("Привет, Мир!"))
|
c.W.Write([]byte("Привет, Мир!"))
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
).Def(
|
||||||
|
"web",
|
||||||
|
bond.Static("./static"),
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -23,3 +23,6 @@ func (fn ContextFunc) ServeHTTP(w ResponseWriter, r *Request) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Static(pth string) Handler {
|
||||||
|
return http.FileServer(http.Dir(pth))
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package bond
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
//"fmt"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ func (router *Router) ServeHTTP(w ResponseWriter, r *Request) {
|
||||||
prefix = path.Clean("/" + name)
|
prefix = path.Clean("/" + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Path: %q\n", r.URL.Path)
|
//fmt.Printf("Path: %q\n", r.URL.Path)
|
||||||
fmt.Printf("%q %q %q %q\n", pth, prefix, pths, name)
|
//fmt.Printf("%q %q %q %q\n", pth, prefix, pths, name)
|
||||||
handler, ok := router.pathMap[name]
|
handler, ok := router.pathMap[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
|
|
5
static/file.html
Normal file
5
static/file.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html><head>
|
||||||
|
</head><body>
|
||||||
|
THE STATIC FILE
|
||||||
|
</body></html>
|
Loading…
Reference in a new issue