The main objective of this project is to learn the Go programming language and explore its packages available in the documentation. Initially, with the creation of a simple API, and later making it more complex, inserting logs, tests and nested endpoint documentation.
This project contains 7 API's endpoints, 6 of which are directly linked with a CRUD process to a postgres database.
For basic interaction, you can use Swagger (via browser) or Insomnia (importing the yaml that contains the essential config to init the use).
The postgres database and the pgadmin are already configured, ready for use.
Some test cases were created that can be started with the command
go test
.
The Project has a mirrored structure in an MVC pattern.
Docker and Docker Compose installed in your machine
Any Linux operating system or Linux subsystem
The initial command can be the following:
chmod +x start.sh
./start.sh
After the first run, it may be necessary to run an increment to clean up the database directory for new run's:
sudo rm -Rf postgres-data && ./start.sh
The following private addresses are fixed in the Docker-Compose configuration, and give access to project options:
http://172.33.0.4:9000/api/v1/
grants access to API and Swagger endpoints.http://172.33.0.3/
grants access to PGAdmin that already has the configuration with the database. Use for login in pgadmin: "[email protected]" and "123456" and for confirmation to access database, the password is "foobar".172.33.0.2
is the IP address of the database, accessible with the credentials foobar:foobar:foobar on port 5432.
In application options, from the Document or Collection name dropdown menu, select Import/Export. Select an option from the Import Data dropdown menu. Import the file "Insomnia_api-go-gin.yaml". For more information: Insomnia Documentation
go test
GET http://172.33.0.4:9000/api/v1/foobar/mock
To shown mockPOST http://172.33.0.4:9000/api/v1/foobar/
To create FoobarGET http://172.33.0.4:9000/api/v1/foobar/
To shown all FoobarGET http://172.33.0.4:9000/api/v1/foobar/:id
To shown Foobar by IDGET http://172.33.0.4:9000/api/v1/foobar/:reg
To shown Foobar by RegistrationPATCH http://172.33.0.4:9000/api/v1/foobar/:id
To edit Foobar by IDDELETE http://172.33.0.4:9000/api/v1/foobar/:id
To delete Foobar by IDGET http://172.33.0.4:9000/api/v1/swagger/index.html
Swagger
end of README.md