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 the week_1 http server section #2

Open
barneymorris opened this issue Dec 4, 2023 · 1 comment
Open

Fix the week_1 http server section #2

barneymorris opened this issue Dec 4, 2023 · 1 comment

Comments

@barneymorris
Copy link

At week_1/http/cmd/http_client/main.go
this line

getPostfix  =  "/notes/%d"

has to be

getPostfix  =  "/notes/{id}"

because otherwise each time you client call the server it always get 404.

From go-chi docs:

// Regexp url parameters:
r.Get("/{articleSlug:[a-z-]+}", getArticleBySlug)                // GET /articles/home-is-toronto
@DementevVV
Copy link

const (
    getPostfix = "/notes/%s" // Use a string parameter
)
r.Get(fmt.Sprintf(getPostfix, "{id}"), getNoteHandler)

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

2 participants