Show HN: Goyave – Golang Web Framework
github.com
github.com
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.
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.Very interesting project. Good job. :)
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.
https://github.com/avelino/awesome-go/pull/1137
http://www.florinpatan.ro/2016/10/why-you-should-not-use-iri...
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.
Everything that can read json has the ability to read yaml. Please use yaml instead.
They just need to have a version of JSON with comments: JSONC and JSON is good.
JSON as config isn't good, but YAML is not a silver bullet.
[1] https://github.com/redhat-developer/vscode-yaml/blob/master/...
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.
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.