kataras on go_modules
kataras on master
Bump github.com/klauspost/compr… (compare)
dependabot[bot] on go_modules
Bump github.com/klauspost/compr… (compare)
kataras on master
Bump github.com/tdewolff/minify… (compare)
kataras on go_modules
dependabot[bot] on go_modules
Bump github.com/tdewolff/minify… (compare)
kataras on master
minor (compare)
kataras on master
Bump github.com/tdewolff/minify… (compare)
kataras on go_modules
dependabot[bot] on go_modules
Bump github.com/tdewolff/minify… (compare)
go: github.com/kataras/iris/v12@v12.2.0-alpha requires
gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776/go.mod: verifying module: gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776/go.mod: cannot authenticate record data in server response
. Any idea how to sort the issue?
Hi folks, I am getting the following error running iris -
go: github.com/kataras/iris/v12@v12.2.0-alpha requires gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776/go.mod: verifying module: gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776/go.mod: cannot authenticate record data in server response
. Any idea how to sort the issue?
^ Fixed by zapping the current GOPATH, looks like a local issue with go mod.
go clean --modcache
? If so, maybe we should add it to the installation's troubleshooting section.
Hi, @kataras when I use "Upload files", I found
app.Post("/upload", func(ctx iris.Context) {
...
.......
file, _, err:= ctx.FormFile("file")
if err != nil {
ctx.StopWithError(iris.StatusBadRequest, err)
return
}
// Upload the file to specific destination.
//the file does not have Filename property,
dest := filepath.Join("./uploads", file.Filename)
ctx.SaveFormFile(file, dest)
ctx.Writef("File: %s uploaded!", file.Filename)
})
the file does not have Filename property(use go1.15 version!),but the method ctx.FormFile("file") return result:fileHeader have the Filename property.So the document have some problem!
So the correct code is:
app.Post("/upload", func(ctx iris.Context) {
// Set a lower memory limit for multipart forms (default is 32 MiB)
ctx.SetMaxRequestBodySize(maxSize)
// OR
// app.Use(iris.LimitRequestBodySize(maxSize))
// OR
// OR iris.WithPostMaxMemory(maxSize)
// single file
file, fileHeader, err:= ctx.FormFile("file")
if err != nil {
ctx.StopWithError(iris.StatusBadRequest, err)
return
}
// 这个地方应该使用fileHeader来获取文件名(go 1.15version).
//我不知道是不是go的版本的问题,我没有去查看go之前的版本
dest := filepath.Join("./uploads", fileHeader.Filename)
ctx.SaveFormFile(file, dest)
ctx.Writef("File: %s uploaded!", file.Filename)
})
and the ctx.FormFile source code is:
func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error) {
// we don't have access to see if the request is body stream
// and then the ParseMultipartForm can be useless
// here but do it in order to apply the post limit,
// the internal request.FormFile will not do it if that's filled
// and it's not a stream body.
if err := ctx.request.ParseMultipartForm(ctx.app.ConfigurationReadOnly().GetPostMaxMemory()); err != nil {
return nil, nil, err
}
return ctx.request.FormFile(key)
}
On a CMS sort of site I think you have a database entry for every pages and one or more template types associated and generated dinamically.
Another solution is to generate a static site based on Hugo and Netlify CMS, that for simple CMS is what I use today. It’s faster and simple to deploy.
Hello @vuhoanglam,
The ctx.View
returns an error
. This error is always logged to your terminal screen (or log file) if the logger is not disabled.
If the application is running under debug log level (app.Logger().SetLevel("debug")
) then the client will receive the error text too but if not (default behavior) then it just returns the error the caller, so you can catch it.
Example Code:
<!-- ./view/fallback.html -->
<h1>Fallback view of {{.ViewRequested}}</h1>
package main
import (
"github.com/kataras/iris/v12"
)
const defaultViewName = "fallback"
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./view", ".html"))
app.Get("/", index)
app.Listen(":8080")
}
func index(ctx iris.Context) {
var viewName = "blabla"
err := ctx.View(viewName)
if err != nil {
ctx.View(defaultViewName, iris.Map{
"ViewRequested": viewName,
})
}
}
I assume you just want to render something as 'fallback' - that you can do already as shown above.
Now, if you are asking if you can disable this log line of "template x does not exist" then it's a different thing. We can create a config field in order to disable that message :)