I tried to set an the result of requestid.Get(ctx) into ViewData globally using app.Use(...) -- however, it turns out that neither of these app.Use(...) functions are actually being called when triggered by an OnErrorCode as seen in the screenshot / example code.

|Thing|Version|
|-|-|
|Golang|1.14.6 linux/amd64|
|Iris|master d0d7679|
|Kernel|5.7.14-200.fc32.x86_64|
|OS|Fedora 32 Workstation|
// ... during app initialization
app.Use(requestid.New())
app.Use(func(ctx iris.Context) {
ctx.ViewData("domain", *domain)
ctx.ViewData("requestID", requestid.Get(ctx))
ctx.Next()
})
// ... when attaching the OnErrorCode
your := app.Subdomain("your")
your.Get("/", slashHandler)
your.OnErrorCode(iris.StatusNotFound, slashHandler)
// ... later in the 404 handler
ctx.ViewData("canon", fmt.Sprintf("%s%s", *domain, path))
ctx.ViewData("langCode", lang)
ctx.ViewData("pageURL", path)
ctx.ViewData("title", fmt.Sprintf("%s - Not Found", *baseTitle))
ctx.StatusCode(iris.StatusNotFound)
if err := ctx.View("404.html"); err != nil {
ctx.StatusCode(iris.StatusInternalServerError)
ctx.Writef(err.Error())
}
Yes that's not a BUG, it's behaving like that because we want to. The Party.Use/Done handlers are not running to error codes. This is why the new Party.UseError was introduced a minute ago, this is the same exact issue of #1588. @AlbinoGeek
UseError has done exactly what I needed here, thank you -- such as protecting error pages of otherwise protected subdomains and parties.
You are welcome, always!!
Most helpful comment
Yes that's not a BUG, it's behaving like that because we want to. The
Party.Use/Donehandlers are not running to error codes. This is why the newParty.UseErrorwas introduced a minute ago, this is the same exact issue of #1588. @AlbinoGeek