Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ctx.NextOrNotFound() is running in loop #1473

Closed
Dexus opened this issue Mar 21, 2020 · 0 comments
Closed

[BUG] ctx.NextOrNotFound() is running in loop #1473

Dexus opened this issue Mar 21, 2020 · 0 comments

Comments

@Dexus
Copy link

Dexus commented Mar 21, 2020

Describe the bug
If you use the ctx.NextOrNotFound() function in middlewares you will run it in loop...

To Reproduce

package main

import (
	"fmt"
	"log"

	"github.com/kataras/iris/v12"
)

func main() {
	app := iris.New()
	app.Logger().SetLevel("debug")

	app.Get("/", getMiddleware1, getMiddleware2, getIndex)
	// Read the README.md before any action.
	err := app.Run(iris.Addr(":8081"))
	if err != nil {
		log.Fatal(err)
	}
}

func getIndex(ctx iris.Context) {
	ctx.Text("Page")
}

func getMiddleware1(ctx iris.Context) {
	fmt.Println("Middleware 1")
	ctx.NextOrNotFound()
}

func getMiddleware2(ctx iris.Context) {
	fmt.Println("Middleware 2")
	ctx.NextOrNotFound()
}

Expected behavior
The Middelware 2 should only run once... not in loop!

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.
  • Iris Version: 12.1.8
@kataras kataras added this to the v12.2.0 milestone Mar 22, 2020
kataras added a commit that referenced this issue Mar 24, 2020
@Dexus Dexus closed this as completed Jun 14, 2020
kataras added a commit that referenced this issue Jul 26, 2020
Former-commit-id: 3e7d927761a5d5559b65ea3f91b94e3dc523a187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants