Here I will talk about Go language.

My main purpose here is to share some things I learn all this time working with this awesome language.

Different approaches to do Pagination in an API Rest

Introduction In this post, I will talk about Pagination in Rest API, my idea was only to talk about that topic and create a tiny repository where I can show a simple example. But I started adding some features, like Docker, Kubernetes, Makefile, etc. (sometimes that kind of thing happens 😀) That made me think that I can explain many topics with the same repository, the idea will be to add more features or technologies and every post will be related to un tag version. [Read More]

How to Write a Pub Sub Service With Go

An overview of the Pub/Sub pattern and how it works. What is Pub/Sub? The Pub/Sub (publish/subscribe) pattern is a messaging pattern used in distributed systems to enable asynchronous communication between components or systems. It allows for the decoupling of senders (publishers) and receivers (subscribers) by introducing an intermediary called a message broker or message bus. How does its work? Publishers: Publishers are responsible for sending messages to specific topics. A topic is a named channel or category to which messages can be published. [Read More]

Working With Websocket

What are websockets and why are they important for web applications? WebSockets are an essential technology for enabling two-way communication between a client and a server over a single (Enable real-time communication), long-lived connection. They provide real-time, low-latency communication between a web application and a server, allowing for a more interactive and dynamic user experience. Are a separate implementation on top of TCP, unlike HTTP. They were standardized by the IETF as RFC 6455 in 2011, and the current API specification allowing web applications to use this protocol is known as websockets. [Read More]

Building an Authorization Service With Fiber Using JWT

What is JWT? JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA. Although JWTs can be encrypted to provide secrecy between parties, we will focus on signed tokens. [Read More]

Build your own OAuth2 server

What is OAuth2? OAuth 2.0, which stands for “Open Authorization”, is a standard designed to allow a website or application to access resources hosted by other web apps on behalf of a user. It replaced OAuth 1.0 in 2012 and is now the de facto industry standard for online authorization. OAuth 2.0 provides consented access and restricts actions of what the client app can perform on resources on behalf of the user, without ever sharing the user’s credentials. [Read More]

Basics about a gRPC Server

What’s gRPC? gRPC is a Remote Procedure Call (RPC) framework. RPC is an action-based paradigm, similar to remotely calling a function from another microservice. This makes gRPC a type of inter-process communication (IPC) protocol built around Protobufs to handle messaging between the client and the server. gRPC is perfect for intensive and efficient communication, because it supports client and server streaming. Difference with REST? In contrast, REST is a resource-based protocol, which means the client tells the server what resource needs to be created, read, updated, or deleted based on the body of the request. [Read More]

Rest Api Design

Maybe I should have written this article before the previous one. But sometimes one doesn’t know where to start, so now I will explain what you need to take care of when you design a Rest API. Why? Designing a REST API follows specific design principles that allow for flexibility, scalability, and independence between client and server applications. The design should follow the six REST design principles to ensure uniformity, decoupling, statelessness, cacheability, a layered system, and optional code on demand. [Read More]

Documenting Api With Swag

Think on this, you’ve finished developing a new API, and now have to write documentation to guide you when building client-side applications that consume the API. You start thinking of various ways to achieve this, and you lay out multiple alternatives like Swagger, Docusaurus, Postman and many more. You remember all the work involved in the API documentation phase and wonder if there are shortcuts to speed things up. You need to do this because who will use an API without any documentation? [Read More]

Graceful Shutdown

How to implement a graceful shutdown in Go? You need to start thinking about these kinds of questions when creating a server that needs to maintain a state. For example, if you have a web server running in one AWS EC2 instance and you fix some security issues and want to update the server. If you don’t manage correctly maybe you can lose the data that never was saved in the database or can provoke some bad user experience on every update because lose all connections without any response to the requests because you don’t wait to finish sending the response. [Read More]