#Web

59 articles

10 Adding Simple Authentication

10 Adding Simple Authentication

At this stage we will try to add simple Authentication by using middleware in Golang. You need to know that middleware is the process of intercepting an API which before the service when accessed goes to the *handler * layer, it will pass through this * middleware * layer (which we will create) to capture and process something for certain needs. For example, in this case we will intercept the service process to see if the API has a header with the key condition X-API-Key.

09 Configuring HTTP Router, HTTP Server and Database Connection

09 Configuring HTTP Router, HTTP Server and Database Connection

At this stage we will create the main function of the project that we have created. In the main function we will add several function initializations which are used to initialize all the resources needed by the project such as database connections, handler initialization, usecases and repositories that we have previously created.

08 Adding a Request Validator Using Golang Playground

08 Adding a Request Validator Using Golang Playground

At this stage we will add validation for each request sent to the API Application on our Services for example on add, change and delete requests. The validation we use is package github.com/go-playground/validator.

07 Creating a Handler as a Data Delivery Layer

07 Creating a Handler as a Data Delivery Layer

At this stage we will continue the project that we have created by creating a Delivery Layer. This layer as explained earlier is a layer that connects user requests with the logic layer.

06 Creating Usecases as Data Logic

06 Creating Usecases as Data Logic

This time we will continue the project of making this RESTFul API by creating a Usecase function. Previously it was discussed that this Usecase Layer will contain logic data or data processing which is used some logic needed in a process.

05 Creating a Repository as Access Data

05 Creating a Repository as Access Data

This time we will create an Article Repository that needs to communicate to the MySQL database. We have a table in MySQL previously explained, then we will create functions that will be used for API specification needs. Here are the functions that we will like this

04 Implementing Clean Architecture on Project

04 Implementing Clean Architecture on Project

At this stage we will try to implement Clean Architecture, where this concept according to Uncle Bob has 4 layers, namely

03 Creating a Database on MySQL Golang

03 Creating a Database on MySQL Golang

At this stage we will try to create a database on MySQL in preparation for creating the table that we will also use later to create an API with the data in the database. Previously, if you didn’t have MySQL on a computer or laptop, prepare to install MySQL and the Database Editor first, you can use DBeaver, MySQL Workbench or what you usually use for database management.

02 Membuat API Specification menggunakan OpenAPI

02 Membuat API Specification menggunakan OpenAPI

At this stage we will try to create all the API Specifications related to the API that we will create so we need complete documentation using OpenAPI. If you haven’t installed OpenAPI in the repository, try reading the previous article first.

01 RESTful Introduction to Golang

01 RESTful Introduction to Golang

Introduction to RESTFul API

Quoted from the amazon website, RESTful API is an interface used by two computer systems to securely exchange information over the internet. Most business applications must communicate with other internal and third-party applications to perform various tasks. For example, to generate monthly payslips, your internal accounts system must share data with your customers’ banking systems to automate billing and communicate with internal time and attendance applications. RESTful APIs support this exchange of information because they follow software communication standards that are secure, reliable and efficient.

09 How To Use Streaming Encoder

09 How To Use Streaming Encoder

Introduction to Stream Encoders

Apart from JSON Decoder, this JSON package can also support Encoder which is used directly JSON into io.Writer. So that way we don’t need to store the JSON data first into a string or []byte variable, so we can just write it directly into io.Writer.

08 How To Use Streaming Decoder

08 How To Use Streaming Decoder

Introduction to Stream Decoder

In the previous article, we studied the JSON package by using conversion of JSON data which was already in the form of variables and string data or we used []byte. Sometimes the JSON data comes from input in the form of io.Reader, which can be in the form of a file, network or request body. So we could just read all the data first, then store it in a variable and then convert it from JSON, but we don’t need to do this because the JSON package has a feature for reading data from Stream.