Browse Source

En cours de développement

master
losyme 4 months ago
parent
commit
61c334a6c1
  1. 5
      router/subrouter.go

5
router/subrouter.go

@ -98,7 +98,8 @@ func (sr *SubRouter) Group(path string, fn func(*Group)) {
}
func (sr *SubRouter) ServeFiles(path string, fs http.FileSystem) error {
const suffix = "/:filepath"
const param = "filepath"
const suffix = "/:" + param
if len(path) < 10 || path[len(path)-10:] != suffix {
return errors.New("path must end with "+suffix, "path", path) //////////////////////////////////////////////////
@ -107,7 +108,7 @@ func (sr *SubRouter) ServeFiles(path string, fs http.FileSystem) error {
fileServer := http.FileServer(fs)
sr.Get(path, func(c *context.Context) error {
c.Request.URL.Path = c.Param("filepath")
c.Request.URL.Path = c.Param(param)
fileServer.ServeHTTP(c.Response, c.Request)
return nil

Loading…
Cancel
Save