4 ms·
Doesn't the Go standard library do what you mentioned above?
by jjtheblunt 4y ago
Doesn't the Go standard library do what you mentioned above?
- tusharsoni 4y agoIt kinda does but there's a lot of boilerplate that goes in before we actually get to the app logic. And, understandably, there's no structure provided by the Go stdlib. Once I made many projects with just using stdlib, I started taking common packages out. And Copper is essentially that. I can start writing my app code with minimal setup / boilerplate.
- atwood22 4y agoGo’s HTTP routing is very primitive. That’s one big area that I’ve always needed to use a 3rd party dependency. The main issue is that it doesn’t support placeholder values in route paths.
- telesoft 4y ago>The main issue is that it doesn’t support placeholder values 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.
- evilthrow 4y agoGET /{username}
- telesoft 4y agoYou definitely don't need a framework to get the user name out of a URL, you need one line of code.
- evilthrow 4y agoAnd 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.
- morelisp 4y agoIt'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.
- telesoft 4y agoAssuming the url is formatted correctly: strings.Split(urlString, "user/")[1] https://go.dev/play/p/tWi-Ge0CA1X https://go.dev/play/p/tWi-Ge0CA1X That's one way to do it. >more URL parameters I thought thats what http.Request.ParseForm() was for (assuming correct formatting)
- morelisp 4y ago> 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.