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]: Naming for Middlewares #2467

Closed
3 tasks done
efectn opened this issue May 17, 2023 · 1 comment · Fixed by #2477
Closed
3 tasks done

🐛 [Bug]: Naming for Middlewares #2467

efectn opened this issue May 17, 2023 · 1 comment · Fixed by #2477

Comments

@efectn
Copy link
Member

efectn commented May 17, 2023

Bug Description

Currently naming on middlewares just working for last element of RequestMethods slice (it's PATCH as default). That's not expected behavior and it needs to be fixed.

Path: /, Method: GET, Name: 
Path: /, Method: HEAD, Name: 
Path: /, Method: POST, Name: 
Path: /, Method: PUT, Name: 
Path: /, Method: DELETE, Name: 
Path: /, Method: CONNECT, Name: 
Path: /, Method: OPTIONS, Name: 
Path: /, Method: TRACE, Name: 
Path: /, Method: PATCH, Name: test

How to Reproduce

Steps to reproduce the behavior:

  1. Add middleware and name it.
  2. Naming will only apply to PATCH method.

Expected Behavior

All methods of middleware should have the name.

Path: /, Method: GET Name: test
Path: /, Method: HEAD, Name: test
Path: /, Method: POST, Name: test
Path: /, Method: PUT, Name: test
Path: /, Method: DELETE, Name: test
Path: /, Method: CONNECT, Name: test
Path: /, Method: OPTIONS, Name: test
Path: /, Method: TRACE, Name: test
Path: /, Method: PATCH, Name: test

Fiber Version

After naming feature introduced

Code Snippet (optional)

package main

import (
	"fmt"

	"github.com/gofiber/fiber/v2"
)

func main() {
	app := fiber.New()

	app.Use(func(c *fiber.Ctx) error {
		return c.Next()
	}).Name("test")

	for _, route := range app.GetRoutes() {
		fmt.Printf("Path: %s, Method: %s, Name: %s\n", route.Path, route.Method, route.Name)
	}
}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.
@ytsruh
Copy link
Contributor

ytsruh commented May 26, 2023

I've submitted a PR for this just now

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

Successfully merging a pull request may close this issue.

2 participants