#Clean Architecture

8 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

Lern RESTFul API Clean Architecture

Lern RESTFul API Clean Architecture

Learn RESTFul API by trying the Clean Architecture method or concept, which is a concept that divides into several components that have independent properties and do not depend on specific external libraries. So that in this concept we are not specifically fixated on a certain Framework or depend on a specific database.