
Show HN: Goyave – Golang Web Framework - SystemGlitch
https://github.com/System-Glitch/goyave
======
TXV
Personally, 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
Fair 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.

------
Jemaclus
Can 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
Thank 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
Excellent. Thank you.

------
eyegor
Anyone 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
There 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-
iri...](http://www.florinpatan.ro/2016/10/why-you-should-not-use-iris-for-
your-go.html)

------
sethammons
I'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.

------
partisan
Those 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
I know the plugins for VS Code can parse them and find errors prior to
building.

------
sneak
Please 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.

~~~
smt88
As 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
Definitely 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/...](https://github.com/redhat-developer/vscode-
yaml/blob/master/README.md)

------
TACIXAT
Integration 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
You 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.

------
dylkil
how does this compare to gin?

~~~
SystemGlitch
Goyave is slower than Gin but provides more features such as regex in routes,
validation, language support, among others.

------
derekdb
We should be

------
shagabutdinov
It'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.

