1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00
Former-commit-id: f4a19eb83a28279782b8a75ee298b38c9e180157
This commit is contained in:
kataras
2017-08-12 08:49:00 +03:00
parent 71af9d7f45
commit e00cf383a2
6 changed files with 119 additions and 52 deletions

View File

@@ -645,15 +645,18 @@ func (rb *APIBuilder) StaticWeb(requestPath string, systemPath string) *Route {
handler := func(ctx context.Context) {
h(ctx)
// re-check the content type here for any case,
// although the new code does it automatically but it's good to have it here.
if ctx.GetStatusCode() >= 200 && ctx.GetStatusCode() < 400 {
if fname := ctx.Params().Get(paramName); fname != "" {
cType := TypeByFilename(fname)
ctx.ContentType(cType)
// re-check the content type here for any case,
// although the new code does it automatically but it's good to have it here.
if _, exists := ctx.ResponseWriter().Header()["Content-Type"]; !exists {
if fname := ctx.Params().Get(paramName); fname != "" {
cType := TypeByFilename(fname)
ctx.ContentType(cType)
}
}
}
}
requestPath = joinPath(fullpath, WildcardParam(paramName))
return rb.registerResourceRoute(requestPath, handler)
}