Via Cep Wrapper is a api wrapper used to find address by zipcode (Brazil only)

Viacep Wrapper

Viacep Wrapper is an API wrapper built with Golang used to find address by zipcode (Brazil only). This project was developed for study purposes.


Architecture

Let's imagine the following challenges to face:

  • we have a 3rd party API that provides us with the postal code service
  • we need to isolate our domain from changes in that service
  • we need to provide all our internal applications with a centralized service that delivers CEP (anti-corruption layer?)

Based on the problems listed above, I created the container diagram below (C4 Model) to exemplify the adopted architecture:

browser response


Project structure

Well, for now, let's just focus on the ViaCep Wrapper API. Although the project itself is very simple, I tried to apply the concepts of Hexagonal Architecture (Ports and Adapters) and the principles of SOLID, such as inversion of control and dependency injection.

NOTE: To develop the api layer and expose the application routes I chose the Fiber framework [https://gofiber.io].

src
 |__adapters
 |  |__api
 |
 |__internal
    |__application
    |__domain

How to test it?

NOTE: before executing the commands below, make sure that Go has been installed correctly [https://go.dev/doc/install].

After clone this repo and inside the 'src' directory run the command:

go run main.go


Sending a command-line request using cURL:

Request

curl http://127.0.0.1:8080/api/find-address-by-zipcode/04543900 \ -H "Accept: application/json"


Response:

{
    "message":"",
    "data": {
        "AddressLine1":"Avenida Presidente Juscelino Kubitschek",
        "AddressLine2":"Vila Nova Conceição",
        "AddressLine3":"1830",
        "City":"São Paulo",
        "State":"SP",
        "Country":"Brazil",
        "ZipCode":"04543-900"
    }
}

If you don't have familiarity with cURL you can use browser to see the response from API:

browser response

Owner
PATRICK SEGANTINE
father, husband, friend... and passionate about information technology... back-end, front-end, cloud, devops etc.
PATRICK SEGANTINE
Similar Resources

Support CI generation of SBOMs via golang tooling.

Software Package Data Exchange (SPDX) is an open standard for communicating software bill of materials (SBOM) information that supports accurate identification of software components, explicit mapping of relationships between components, and the association of security and licensing information with each component.

Jan 3, 2023

DSV Parallel Processor takes input files and query specification via a spec file

DSV Parallel Processor Spec file DSV Parallel Processor takes input files and query specification via a spec file (conventionally named "spec.toml").

Oct 9, 2021

Support CI generation of SBOMs via golang tooling.

Support CI generation of SBOMs via golang tooling.

SPDX Software Bill of Materials (SBOM) Generator Overview Software Package Data Exchange (SPDX) is an open standard for communicating software bill of

Jan 3, 2023

A wrapper for the Wandbox API, written in Golang!

GoWandBox A simple wrapper for the WandBox API, written in Golang! Documentation can be found at classpythonaddike.github.io/gowandbox/ Note: This wra

Sep 19, 2021

Interkassa api wrapper in golang.

Golang https://interkassa.com/ api wrapper (WIP) Как использовать Создаём кассу package main import ( "net/http" "time" "github.com/qystishere/in

Jun 30, 2022

A dead simple Go wrapper around the hidden moonarch.app API.

moonarch A dead simple Go wrapper around the hidden moonarch.app API. How-To First, get the repository: go get github.com/lazdotdigital/moonarch. moon

Nov 27, 2021

A reverse-proxy cache for external images used on LinuxFr.org

External images on LinuxFr.org Our users can use images from external domains on LinuxFr.org. This component is a reverse-proxy / cache for these imag

May 14, 2021

A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.

A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.

one-file-pdf - A minimalist PDF generator in 2K lines and 1 file The main idea behind this project was: "How small can I make a PDF generator for it

Dec 11, 2022

Nomad Pack is a templating and packaging tool used with HashiCorp Nomad.

Nomad Pack is a templating and packaging tool used with HashiCorp Nomad.

Jan 4, 2023
AutoK3s GEO collects metrics about locates remote IP-address and exposes metrics to InfluxDB.

AutoK3s GEO AutoK3s GEO collects metrics about locates remote IP-address and exposes metrics to InfluxDB. Thanks to https://freegeoip.live/ which prov

Jun 16, 2022
using go search the Marvel universe characters via marvel api
using go search the Marvel universe characters via marvel api

go-marvel-api using go search the Marvel universe characters via marvel api Build and run tests on the local environemnt Build the project $ go build

Oct 5, 2021
Go API wrapper for Greenhouse.io API

Greenhouse IO A Go interface to Greenhouse.io's API Useage Creating the Client NewClient accepts: A context; used for any HTTP requests made using the

Jan 14, 2022
golang script for bypass AV and work only in windows platform
golang script for bypass AV and work only in windows platform

antivirus bypass protection requirements golang installed usage 1 - create your payload go run create.go <ip> <port> <secret> <any url>

Nov 9, 2022
Find strings in Go binaries

gostringsr2 gostringsr2 extracts strings from a Go binary using radare2. Tested with radare2 3.7.0, Python 3.7, r2pipe 1.4.1, on OS X and Linux. Teste

Oct 20, 2022
Find hidden information in JS files for golang

findsecret Find hidden information in JS files Installation Download findsecret.

Dec 26, 2021
A small API to be used in Traefik Forward Auth to block attacks on services behind your favorite web router

Dynamic IPs Blacklist for Traefik This small software implements the possibility to block access to all the services behind your Traefik service. The

Sep 2, 2022
Provides a rest API that used to count how many times a certain repository of your github has been cloned.
Provides a rest API that used to count how many times a certain repository of your github has been cloned.

traffic-clones-api An apiserver for https://shields.io/endpoint. Description Provides a rest API that used to count how many times a certain repositor

Dec 19, 2021
A project that provides an in-memory key-value store as a REST API. Also, it's containerized and can be used as a microservice.

Easy to Use In-Memory Key-Value Store A project that provides an in-memory key-value store as a REST API. Also, it's containerized and can be used as

Mar 6, 2022
:chart_with_upwards_trend: Monitors Go MemStats + System stats such as Memory, Swap and CPU and sends via UDP anywhere you want for logging etc...

Package stats Package stats allows for gathering of statistics regarding your Go application and system it is running on and sent them via UDP to a se

Nov 10, 2022