If you've ever worked with web frameworks like Express.js, you know how convenient and easy to use they can be. Now, imagine this ease in Go, wit...
For further actions, you may consider blocking this person and/or reporting abuse
Nicely done! I once wrote an RPC web server in Go before generics were a thing using the reflect package quite intensively. Writing your own router is such an interesting and sometimes frustrating process. I love the flexibility I have, but you keep discovering corner cases such as OPTIONS header, the obvious CORS, returning errors and subsequently their appropriate error codes etc... Then maybe you want to return a file rather than json and that becomes a thing.
Similar to your code, I never really liked the syntax of adding an additional return line rather than doing it on one line. But maybe that's just a me thing. I also have it in mine.
In any case, this is great stuff. I'm sure those 19h were intense but full of interest and curiosity. From my learnings, I now use what I'd probably say is the standard Mux router. It's not exactly how I'd like to do things, but it's shielded me from a lot of corner cases and has made building my current project (temp mail detector) a lot simpler and quicker.
Congratulations on the project, I'm sure it was rewarding to write it, writing a router is very interesting, even more so when you focus on simplicity. One thing I noticed is, writing generic code is more difficult than it seems, there were a few hours when my brain went wrong and I got stuck, that's why it took me so long. and I'm going to take a look at this mux project, it looks very interesting.
Absolutely. More often than not you write something generic and then realise later on there's a better way to do it. All part of the fun.
Your work is very good. What would be the next step? Create the manipulation of the methods (get, post, pu, delete ...)
I spent yesterday afternoon thinking and made a to-do list, I have some goals for this micro framework, if anyone wants to help, all help is welcome.
1) Implement this manipulation of methods as you said (get, post put and delete)
2) Implement middleware against CSRF, auth middleware, and implement a time out system in the format of a middleware
3) create a website for documentation, with more examples and maintaining colloquial language to make it easier to understand...
4) Improvements in error management and customized responses.
What do you think about enhancing this with next function and w.locals?
The next function I will have to implement after implementing some middlewares and with w.locals did you mean app.locals, or res.locals?
yep. I mentioned w.locals since you used w instead of res as the variable name. Maybe I will raise a pr. What do you think about starting a slack/discord?
I just created a discord channel, if you want to join, this is the link:
You built your own framework 😯. Respect man 🙌
Thanks bro, it was really fun to do, now I want to improve it more and more.
I love stuffs like this but what happened to GoFiber?
Gofiber is cool, but I thought it would also be cool for me to make my own to learn lol Gofiber is much more complex than mine...
Great stuff, we built a set of tools and HTTP router is one such module in our open source library - golly
Do check it out Repository Link
HTTP Router Link
A simple and quick implementation!
I left a ⭐, congratulations on the project, really cool.
Beautiful, thank you for making me contribute to the project, I will do more
I thank you for contributing, your help is very important.
Thanks for doing what Rob Pike never did for us.
He could too, prolly he isn't interested in express js
😂😂😂😂
Have you checked github.com/gin-gonic/gin ?
I had never seen it before, but now I opened the repository, it's pretty cool.