DEV Community

Cover image for Write a Simple REST API in Golang

Write a Simple REST API in Golang

Lucas Neves Pereira on April 13, 2021

Hello there πŸ˜€ In this brief article I will explain how I write a REST API using Golang trying to follow some best practices. The source code to ...
Collapse
 
euantorano profile image
Info Comment hidden by post author - thread only accessible via permalink
Euan T • Edited

Nice thorough guide, but it might be worth mentioning that the recommended practice is to use a custom http.Server with timeouts and such, as described here.

Another useful thing to perhaps mention is using the request context when running DB queries in order to handling timing them out and cancelling them. Contexts are also useful to pass context from middleware to handlers too :)

Collapse
 
lucasnevespereira profile image
Info Comment hidden by post author - thread only accessible via permalink
Lucas Neves Pereira

Thanks, I appreciate your feedback :)

Collapse
 
vladimirstepanov profile image
Info Comment hidden by post author - thread only accessible via permalink

Author's response about this situation:
"Hello there :) I actually delete it because some of the concepts were inspired by other content creators and didn't wanted to disrespect their work. Therefore, I decided to delete that article and rewrite it better."

We'll be wait ^_^

Collapse
 
deven96 profile image
Diretnan Domnan

Nice article!

Collapse
 
lucasnevespereira profile image
Lucas Neves Pereira

I appreciate it :)

Collapse
 
stremovsky profile image
Yuli

Hi,

You are missing a privacy section.

Privacy by design compliance

Privacy by design compliance is a challenging task for most startups. It is better to build it from the first steps of the product. Otherwise, you will have to add privacy to an already developed product. It is much more complicated and much more expensive.

You can build privacy by design on your own, or go with the open-source tools, for example with the Databunker project (databunker.org/). Databunker is a network-based, self-hosted, GDPR compliant, secure storage for personal data.

Self-promotion

I am an open-source security developer. I build and maintain the Databunker project.

Databunker will make your company or service privacy by design compliant and it is absolutely for free.

BR, Yuli

Collapse
 
lucasnevespereira profile image
Lucas Neves Pereira

Hello I appreciate the feedback! I will try to implement it πŸ‘πŸ» I’ll be updating this post with what I learn :)

Collapse
 
cteyton profile image
CΓ©dric Teyton

Hi Lucas, FYI we've added your blog post on a GitHub project gathering content about best coding practices :)
github.com/promyze/best-coding-pra...

Collapse
 
tadeubernacchi profile image
Tadeu Bernacchi

Awesome, thanks for sharing =)

Collapse
 
lucasnevespereira profile image
Lucas Neves Pereira

You're Welcome :)

Collapse
 
vladimirstepanov profile image
Vladimir

Maaaaaaaaaaaaaan! Why do you delete this amazing article??(((

Collapse
 
dmuth profile image
Douglas Muth

Agreed--I came here from a link in an email, and I'm disappointed to see that the entire post was removed.

I think it would have been more appropriate to mark whatever parts of the post may have been in error with a note saying something to the effect, "It has been brought to my attention that this section may not be 100% accurate, and an update is pending"

Collapse
 
fuzzknob profile image
Info Comment hidden by post author - thread only accessible via permalink
Gagan Rai

Thanks for the article. There needs be more go lang articles in this site.

Collapse
 
pratiksinha profile image
Info Comment hidden by post author - thread only accessible via permalink
pratik-sinha

showing 404 :/

Collapse
 
matawed profile image
matawed

The same is true for me. I started reading it and wanted to continue after some time. Now it’s gone.

Some comments have been hidden by the post's author - find out more