1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-02 01:37:11 +00:00

examples: use ctx.ResponseWriter().Naive().(http.Pusher) instead

Former-commit-id: 7802f4eadf2b1c0a0d2a42ed5ebac3e5c77f88cc
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-24 22:36:46 +03:00
parent a4efb222cc
commit 2f8b29cb3d
6 changed files with 18 additions and 82 deletions

View File

@@ -27,7 +27,7 @@ func pushHandler(ctx iris.Context) {
// parent request.
target := "/main.js"
if pusher, ok := ctx.ResponseWriter().(http.Pusher); ok {
if pusher, ok := ctx.ResponseWriter().Naive().(http.Pusher); ok {
err := pusher.Push(target, nil)
if err != nil {
if err == iris.ErrPushNotSupported {

View File

@@ -97,8 +97,11 @@ func main() {
}
app.Get("/", func(ctx iris.Context) {
ctx.View("todos/index.jet", todos) // <--
err := ctx.View("todos/index.jet", todos) // <--
// Note that the `ctx.View` already logs the error if logger level is allowing it and returns the error.
if err != nil {
ctx.StopWithText(iris.StatusInternalServerError, "Templates not rendered!")
}
})
app.Get("/todo", func(ctx iris.Context) {