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

panic: path must begin with '/' in path 'GET' #366

Closed
MaestroJurko opened this issue Mar 26, 2023 · 0 comments
Closed

panic: path must begin with '/' in path 'GET' #366

MaestroJurko opened this issue Mar 26, 2023 · 0 comments

Comments

@MaestroJurko
Copy link

MaestroJurko commented Mar 26, 2023

Hi,

I am moving my handler from net/http / mux to httprouter and my tests are failing. I am doing a request to a server running in a separate go routine. httprouter is complaining that the path must start with /, not sure why.

httprouter implementation:

	mux := httprouter.New()
	mux.HandlerFunc("/api", http.MethodGet, wrapper(s.rootHandler()))

test calling the pth

        req, err := http.NewRequest(http.MethodGet, "http://localhost:8080/api", nil)
	req.Header.Set("Content-Type", "application/json")
	if err != nil {
		return err
	}
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer res.Body.Close() //nolint:errcheck
	if res.StatusCode != http.StatusOK {
		return errors.New("server not yet running")
	}

Not sure it is throwing a panic. It has no issues running with net/http mux.

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