1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

minor version 11.2.2 - register sessions as middleware and Context.HTML/Text like Context.Writef

Former-commit-id: 6f5f1c502fb06d739c350c3ecc891f495dc03a6e
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-07-24 19:51:42 +03:00
parent 275cc14e39
commit 29bf846bd1
10 changed files with 95 additions and 39 deletions

View File

@@ -37,11 +37,11 @@ func (ctx *MyContext) Next() {
// Override any context's method you want...
// [...]
func (ctx *MyContext) HTML(htmlContents string) (int, error) {
func (ctx *MyContext) HTML(format string, args ...interface{}) (int, error) {
ctx.Application().Logger().Infof("Executing .HTML function from MyContext")
ctx.ContentType("text/html")
return ctx.WriteString(htmlContents)
return ctx.Writef(format, args...)
}
func main() {

View File

@@ -28,6 +28,12 @@ func main() {
})
app.Get("/execute", func(ctx iris.Context) {
if !none.IsOnline() {
ctx.Values().Set("from", "/execute with offline access")
ctx.Exec("NONE", "/invisible/iris")
return
}
// same as navigating to "http://localhost:8080/invisible/iris" when /change has being invoked and route state changed
// from "offline" to "online"
ctx.Values().Set("from", "/execute") // values and session can be shared when calling Exec from a "foreign" context.