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

Adding .UseBefore adds the paths into registeredPaths in fasthttp twice #107

Open
susarlanikhilesh opened this issue Oct 10, 2024 · 0 comments

Comments

@susarlanikhilesh
Copy link

package main

import (
	"fmt"

	"github.com/savsgio/atreugo/v11"
)

func main() {
	server := atreugo.New(atreugo.Config{Addr: ":8080"})

	server.GET("/{id}", func(ctx *atreugo.RequestCtx) error {
		return ctx.TextResponse("Hello, World!" + ctx.UserValue("id").(string))
	}).UseBefore(func(ctx *atreugo.RequestCtx) error {
		fmt.Println("Before middleware")
		return nil
	})

	fmt.Println(server.ListPaths())
}

Output: map[GET:[/{id} /{id}] OPTIONS:[/{id}]]

If UseBefore is not added, then it adds once, but having UseBefore adds it again to registeredPath in fasthttp making that array bloated, if every route has a UseBefore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant