Re:Show HN: Copper – A Go framework for your projects
by evilthrow on Saturday July 02, 2022 @10:39AM
(#31959370)
GET /{username}
Re:Show HN: Copper – A Go framework for your projects
by telesoft on Saturday July 02, 2022 @10:54AM
(#31959498)
You definitely don't need a framework to get the user name out of a URL, you need one line of code.
Re:Show HN: Copper – A Go framework for your projects
by evilthrow on Saturday July 02, 2022 @11:46AM
(#31960002)
And what would that line of code be? As far as I am aware you have to parse the URL string, and it only gets more complicated when you add more URL parameters. Which definitely leads to boilerplate code shared across projects.
Re:Show HN: Copper – A Go framework for your projects
by morelisp on Saturday July 02, 2022 @01:09PM
(#31960693)
It's also not especially performant to do the naive (i.e. short) implementation like this, since you'll likely end up parsing/processing path elements left-to-right rather than in whatever order makes the most sense for your loading.
Re:Show HN: Copper – A Go framework for your projects
by telesoft on Saturday July 02, 2022 @01:14PM
(#31960730)
Assuming the url is formatted correctly:
strings.Split(urlString, "user/")[1]
https://go.dev/play/p/tWi-Ge0CA1XThat's one way to do it.
>more URL parameters
I thought thats what http.Request.ParseForm() was for (assuming correct formatting)
Re:Show HN: Copper – A Go framework for your projects
by morelisp on Saturday July 02, 2022 @01:21PM
(#31960772)
> Assuming the url is formatted correctly
... is like, a core job of an HTTP router? You're not just begging the question, you're beating someone up and rifling through their pockets for it.
Can you elaborate? Like give me an example of a route path that uses placeholder values? I use Go to build web apps too and I really don't see a need for anything other than the standard library.