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

fix path conflict #519

Closed
wants to merge 1 commit into from
Closed

Conversation

wusphinx
Copy link
Contributor

It will be panic with gin(v1.1.5-0.20170702092826-d459835d2b07) as below

[GIN-debug] GET    /ping                     --> main.main.func1 (3 handlers)
[GIN-debug] GET    /ping/:id                 --> main.m (3 handlers)
[GIN-debug] GET    /ping/pong/:id            --> main.m (3 handlers)
panic: path segment 'pong/:id' conflicts with existing wildcard ':id' in path '/ping/pong/:id'

so when I config in lura with gin as below

		{
			"endpoint": "/ping/{param1}",
			"output_encoding": "no-op",

			"backend": [{
				"encoding": "no-op",

				"host": [
					"http://127.0.0.1:1234"
				],
				"url_pattern": "/ping/{param1}"
			}]
		},
		{
			"endpoint": "/ping/pong/{param1}",
			"output_encoding": "no-op",

			"backend": [{
				"encoding": "no-op",

				"host": [
					"http://127.0.0.1:1234"
				],
				"url_pattern": "/ping/pong/{param1}"
			}]
		}

I will get the same panic, so, I just upgrade gin to lastest version.
We can get a few clues with this issue and PR. Actuall, the problem has been fixed in Gin,but, we can't get the client ip correctly, becasue as below

func (engine *Engine) Run(addr ...string) (err error) {
	defer func() { debugPrintError(err) }()

	trustedCIDRs, err := engine.prepareTrustedCIDRs()
	if err != nil {
		return err
	}
	engine.trustedCIDRs = trustedCIDRs
	address := resolveAddress(addr)
	debugPrint("Listening and serving HTTP on %s\n", address)
	err = http.ListenAndServe(address, engine)
	return
}

lura doesn't set the trustedCIDRs with gin, so, I just use the function mux.ClientIP instead, and it does work!

Signed-off-by: wusphinx <wu.sphinx@gmail.com>
@kpacha
Copy link
Member

kpacha commented Oct 7, 2021

will be fixed at #524

@wusphinx
Copy link
Contributor Author

wusphinx commented Oct 8, 2021

will be fixed at #524

Looking forward to the official release of v2.0.0

@wusphinx wusphinx closed this Oct 8, 2021
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

This pull request was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants