6 ms·
Show HN: Goyave – Golang Web Framework
- dylkil 7y agohow does this compare to gin?
- SystemGlitch 7y agoGoyave is slower than Gin but provides more features such as regex in routes, validation, language support, among others.
- TACIXAT 7y agoIntegration with auto cert would be really nice. That is usually the biggest chunk in the body of my Go servers' main functions. Edit: Is it also easy to hook up a CRSF middleware? I guess that's my pain point with modern web development. Most cool features need SSL, you should add CSRF protections, gotta pick a good password hashing algorithm. I know how to do it but it's a bunch of tedious work when I just want to hack something together. Would love a framework that streamlines all that.
- SystemGlitch 7y agoYou can give a path to your SSL cert in the config, and set "protocol" to "https" and you're done. If you're using Certbot, give the path to the live cert and it will work even after renewal. About CSRF, as the framework is focused on APIs, the use of cookies is possible but not recommended, so you won't need CSRF protection when using Goyave.
- masa331 7y agoi suggest looking at Rails. It streamlines a lot more than ^^^
- Jemaclus 7y agoCan you elaborate a bit on what features were added on top of the standard library or other popular libraries? A lot of this stuff is very similar to viper (configuration), mux (routing), gorm (database), so I'm wondering if there are additional features on top of those, or maybe the goal was to wrap it all into a single framework for ease of use? Very interesting project. Good job. :)
- SystemGlitch 7y agoThank you! Yes there are quite a lot of features added to the package: - Request validation - Localization (for validation error messages and regular text) - Authentication (with built-in Basic Auth and JWT authenticators, directly using your User model. You can easily implement your own authenticators too) - CORS - Status handlers (for default responses depending on the response status when the body is empty, handy for error handling) - Logging (using Common or Combined log format. You can implement your own formatters too) - Advanced testing with test suites making it easy to write functional tests, unit tests for your middleware, etc. - Database testing with record generators and seeders - Many helpers to make your life easier (that includes multi-values header parsing, file management, automatic 404 when a database record is not found, etc). There are a lot of small things! - An extensive and pretty documentation. This aspect very important to me. I try to make it as flexible as possible to let developers implement things for their specific needs without having to fork the framework.
- Jemaclus 7y agoExcellent. Thank you.
- shagabutdinov 7y agoIt's not a framework. It's just a toolbox and set of libraries. There is no inversion of control which is the core point of frameworks.
- TXV 7y agoPersonally, I would still choose gin. Gin seems to be more straight to the point. To name one, compare goyave router.Route("PUT|PATCH", ...) with gin router.PUT() or router.PATCH(). Also I'm not a fan of adding a lot of functionality and opinionated behavior into web frameworks. e.g. configuration files that need to be in a specific place in my workdir, "automatic 404 when a database record is not found", etc. But sure, if you want to get a server up and running from scratch very quickly for a POC or a simple API-over-a-database app, this lib might be a good starting point.
- SystemGlitch 7y agoFair point. The "automatic 404 when a database record is not found" is purely optional and something you choose to use or not, like all the other helpers. For example, see below code: func Show(response *goyave.Response, request *goyave.Request) { product := model.Product{} id, _ := strconv.ParseUint(request.Params["id"], 10, 64) result := database.GetConnection().First(&product, id) if response.HandleDatabaseError(result) { response.JSON(http.StatusOK, product) } } "response.HandleDatabaseError" is the helper we're talking about.
- hssys 7y agoDoesn't Gin still have big issues where it's not compatible with native net/http middleware?
- eyegor 7y agoAnyone know how this compares to iris? (iris is faster than gin and has a truckload of examples, not sure why it's less popular). https://github.com/kataras/iris/blob/master/README.md https://github.com/kataras/iris/blob/master/README.md
- mosen 7y agoThere was some controversy with its primary maintainer a while ago, not sure how it's progressed since. I can't speak of the technical side, however. https://github.com/avelino/awesome-go/pull/1137 https://github.com/avelino/awesome-go/pull/1137 http://www.florinpatan.ro/2016/10/why-you-should-not-use-iris-for-your-go.html http://www.florinpatan.ro/2016/10/why-you-should-not-use-iri...
- faizmokhtar 7y agothe reason why it's not popular is probably because of the controversy it have before
- sneak 7y agoPlease stop using json for config files. Config files that cannot be commented are terrible for maintainability. Everything that can read json has the ability to read yaml. Please use yaml instead.
- hombre_fatal 7y agoThis is just your arbitrary hobbyhorse opinion about something yet you're saying it with an absoluteness that doesn't make me think you realize that.
- lenkite 7y agoPrefer toml over yaml. Large Yaml files are a nightmare to edit with all the special spacing. JSON might be comment unfriendly but it is easily editable. They just need to have a version of JSON with comments: JSONC and JSON is good.
- smt88 7y agoAs a heavy YAML user for a while (writing and maintaining Open API Spec files), YAML is also a catastrophe. I should not have to "debug" a config file because some tiny whitespace issue is off. JSON as config isn't good, but YAML is not a silver bullet.
- haar 7y agoDefinitely agree that YAML is not a silver bullet. One thing that I’ve found to improve my YAML editing experience is to use a YAML language server [1] backed by JSON schemas. It provides a real time feedback cycle rather than handing the file off to another program to choke cryptically. [1] https://github.com/redhat-developer/vscode-yaml/blob/master/README.md https://github.com/redhat-developer/vscode-yaml/blob/master/...
- atraac 7y agoJSON5 supports comments. NET Core has been working with comments inside .json appsettings files for a very long time now.
- derekdb 7y agoWe should be
- partisan 7y agoThose validation rules are scary to look at. They are cryptic strings that express some limited form of logic in that can only be verified at runtime. Is this the state of the art for Go?
- dougbarrett 7y agoI know the plugins for VS Code can parse them and find errors prior to building.
- sethammons 7y agoI'm not a fan of non-standard-lib compatible routers. I understand why the op chose to do so, but it doesn't jive with being able to change the implementation later. I'm a fan of Chi for routing and it it compatible with the standard lib. I'm def in the camp of pulling in libraries vs full frameworks. That said, there is always room for improvement for the development workflow, especially for rapid prototyping. I'd be interested in a side by side comparison between this and the other batteries-included web frameworks such as Gin, Buffalo, Beego, Revel, and the standard lib.