1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

Update to version 8.5.6 | Read HISTORY.md

Former-commit-id: 3c1fb7ad47d54133f68ee0ee8ebe4c3835fe4ce0
This commit is contained in:
kataras
2017-11-05 04:12:18 +02:00
parent ef41e07d4e
commit af9a1f1241
33 changed files with 587 additions and 307 deletions

View File

@@ -599,15 +599,9 @@ func (api *APIBuilder) StaticHandler(systemPath string, showList bool, gzip bool
return StaticHandler(systemPath, showList, gzip)
}
// StaticServe serves a directory as web resource
// it's the simpliest form of the Static* functions
// Almost same usage as StaticWeb
// accepts only one required parameter which is the systemPath,
// the same path will be used to register the GET and HEAD method routes.
// If second parameter is empty, otherwise the requestPath is the second parameter
// it uses gzip compression (compression on each request, no file cache).
//
// Returns the GET *Route.
// StaticServe serves a directory as web resource.
// Same as `StaticWeb`.
// DEPRECATED; use `StaticWeb` or `StaticHandler` (for more options) instead.
func (api *APIBuilder) StaticServe(systemPath string, requestPath ...string) *Route {
var reqPath string
@@ -619,22 +613,7 @@ func (api *APIBuilder) StaticServe(systemPath string, requestPath ...string) *Ro
reqPath = requestPath[0]
}
return api.Get(joinPath(reqPath, WildcardParam("file")), func(ctx context.Context) {
filepath := ctx.Params().Get("file")
spath := strings.Replace(filepath, "/", string(os.PathSeparator), -1)
spath = path.Join(systemPath, spath)
if !DirectoryExists(spath) {
ctx.NotFound()
return
}
if err := ctx.ServeFile(spath, true); err != nil {
ctx.Application().Logger().Warnf("while trying to serve static file: '%v' on IP: '%s'", err, ctx.RemoteAddr())
ctx.StatusCode(http.StatusInternalServerError)
}
})
return api.StaticWeb(reqPath, systemPath)
}
// StaticContent registers a GET and HEAD method routes to the requestPath