static.go 319 B

1234567891011121314151617181920
  1. package ss
  2. import (
  3. "net/http"
  4. )
  5. func StaticDir(pth string) Handler {
  6. return Wrap{
  7. UseRelUrl: true,
  8. HttpHandler: http.FileServer(http.Dir(pth)),
  9. }
  10. }
  11. func StaticFile(pth string) Handler {
  12. return Wrap{
  13. HttpHandler: HttpHandlerFunc(func(w ResponseWriter, r *Request){
  14. http.ServeFile(w, r, pth)
  15. }),
  16. }
  17. }