Programming
109 Artikel tersedia

18 Building Cross-Origin Resource Sharing (CORS) Middleware Using the `httprouter` Library in Golang
Cross-Origin Resource Sharing (CORS) is a security mechanism that allows or restricts HTTP requests from different domains. In web application development, it is often necessary to interact with APIs that do not originate from the same domain as the application. Therefore, CORS middleware is required to control and grant access from different origins, ensuring that requests from various sources can be safely accepted and processed by the server.

17 Creating Certificate-based Authentication (SSL/TLS) Middleware in Go
In this article, we will learn how to create middleware for certificate-based authentication (SSL/TLS) using the httprouter
library in Go. SSL/TLS is a widely used protocol for enhancing internet communication security, ensuring that only authorized parties can communicate with the server. This middleware will help us verify whether a client provides a valid certificate before accessing an endpoint.

16 Building HMAC Authentication Middleware Using `httprouter` in Golang
In this article, we will discuss how to build an HMAC (Hash-based Message Authentication Code) authentication middleware using Go and the httprouter
library. This middleware functions to authenticate HTTP requests based on an HMAC signature, ensuring data integrity and verifying that the data originates from a trusted source.

15 Creating Session-based Authentication Middleware Using `httprouter` in Golang
In this article, we will walk through the steps of building Session-based Authentication Middleware using Golang and the httprouter
library. This middleware will help verify user sessions for incoming HTTP requests.

14 How to Build API Key Authentication Middleware with Unit Tests Using `httprouter` in Golang
APIs (Application Programming Interfaces) play a crucial role in connecting various applications or services. To ensure your application remains secure and protected from unauthorized access, implementing authentication methods such as API Key Authentication is essential. In this article, we will go through a step-by-step guide on how to create API Key Authentication middleware using httprouter
in Golang, along with unit tests for each function to ensure reliability.

13 Building OAuth 2.0 Authentication Middleware with `httprouter` in Go
In modern programming, application security is a top priority, especially when dealing with user authentication. One widely used authentication method today is OAuth 2.0, which allows applications to access user resources without exposing their credentials. In this article, we will discuss how to create an authentication middleware using OAuth 2.0 with Go and the httprouter
library.

12 Creating Static File Handler
In web applications, serving static files such as images, CSS files, or JavaScript from a public directory is often necessary. By using the julienschmidt/httprouter library, you can easily create a handler to serve static files. This article will walk you through the complete steps to implement a static file handler in a simple and efficient way using Golang.

11 Membuat Middleware Basic Authentication HTTP Router pada Golang
Basic Authentication is a simple authentication method where the client sends credentials (username and password) in the header of each HTTP request. In this article, we will learn how to create Basic Authentication middleware in Golang using the httprouter library.

10 Creating Authentication Middleware Using JWT with Httprouter in Golang
In modern application development, authentication is one of the most crucial components. JSON Web Tokens (JWT) is a popular method for handling token-based authentication. In this article, we will create an authentication middleware using JWT in Golang with the httprouter
library from julienschmidt.

09 How to Set Headers on Requests and Responses Using Httprouter in Golang
In web development, managing HTTP request and response headers is crucial for handling data, security, and metadata. This article provides a step-by-step guide on setting headers using the httprouter library in Golang. With this guide, even beginners can grasp the concept with ease.

12 Creating Dependecy Injection Library Google Wire
This time we will try to make Dependency Injection using the Wire Library from github.com/google/wire. The usefulness of this library is that we can make so many dependencies that we can generate directly concisely and easily.

11 Add Unit Tests Using Mockery
At this stage we will need the following dependencies
brew install mockery
go get github.com/stretchr/testify
go mod tidy
go mod vendor
go get github.com/DATA-DOG/go-sqlmock
In this project we will try to create unit tests using a mocking library with the name mockery
. This library is widely used by golang developers because of its ease of use and has the advantage of features that can cover all the necessary unit tests. If you have used unit tests in golang, you may already know this library but if you want to get more references, Santekno has also provided previous posts including: