Is this API attempt breaking any rules?

Well, then I guess I have to move to Nginx + Node.js + React or similar to get the templating. Having a small journey with Angular which was sort of spinning wheel experience. For now I will go for Go which is far simpler and more predictable than JS. https://gowebstatic.tk/why

Yup, JS also gives me trouble, every time…

But doing server side rendering in Go also works.

The other question I have about the API is the schema.
Usually you will define your schema as a struct, rather than an empty interface.
Using an empty interface means that you loose the type safety of Go, and you
don’t have an explicit definition of the schema of your API calls.
On the other hand, if you have 1000 tables, each with a different schema, then it
will become quite tedious to define 1000 separate structs.
(If, on the other hand, all the tables have the same schema, then they should be combined).

If you decide to go with an explicit schema, then it is worth looking at an orm such as https://gorm.io/
which will define your tables, and generate all the db operations for you.

It is worth adding some unit tests. Go has excellent tooling for this.
Francesco Camploy has a great video demonstrating the common patterns

OT, but as you are not using nginx, you might want to look at
https://github.com/caddyserver/certmagic to do the SSL termination and cert management of your site.

Today I have about 100 tables, but as the number of columns vary from each query, I guess that I will have more structs. I cannot imaging that fetching one column may have same struct as 50 columns?

Gorm is like JQuery to Vanilla Javascript. Another language upon another layer. I want to avoid any de-layer :slight_smile:

Thank you! I will have a closer look at this.

Why not the built in SSL?

err := http.ListenAndServeTLS(":443", "server.crt", "server.key", nil)

Yes the built in SSL is solid. But you have to get “server.crt”, “server.key”.

Certmagic handles getting a letsEncrypt SSL key for you.

So instead of
http.ListenAndServeTLS(":443", "server.crt", "server.key", nil)

you call
certmagic.HTTPS([]string{"sibert.com"}, nil)

and it generates the certificates for you, and renews them when necessary.

There are two but. Sometimes letsEncrypt is not “safe enough”. And Caddy adds another server to manage. You always have to pay for the magic…

You don’t need Caddy.
certmagic is a stand alone library, from code originally written for Caddy.
So no other servers to manage.
The best things in life are free…

Good to know. Thank you!