myAPP - Demo Rest API created with Go (Golang)
2.9K
Este proyecto es una demostración de cómo crear una API REST en Go para fines educativos. La API proporciona diversos endpoints que permiten a los usuarios realizar operaciones CRUD (crear, leer, actualizar y eliminar) en una base de datos. También se ha implementado un sistema de autenticación y autorización mediante el uso de tokens JWT.
Además, se han utilizado técnicas de optimización y mejora de seguridad, como Middleware para validar los argumentos de entrada y para agregar cabeceras de seguridad a las respuestas HTTP.
En resumen, este proyecto es una buena demostración de cómo crear una API REST segura y escalable en Go y puede ser utilizado como base para proyectos más complejos.
This project is a demonstration of how to create a REST API in Go for educational purposes. The API provides various endpoints that allow users to perform CRUD (create, read, update, delete) operations on a database. An authentication and authorization system has also been implemented using JWT tokens.
In addition, optimization and security enhancement techniques have been used, such as Middleware to validate input arguments and to add security headers to HTTP responses.
In summary, this project is a good demonstration of how to create a secure and scalable REST API in Go and can be used as a base for more complex projects.
| Endpoint | HTTP method | Description |
|---|---|---|
/login | POST | Start a session and get an authentication token |
/customers | GET | Get a customer by document number |
/customers | GET | Get a customer by customer number |
/customers/list | GET | Get a list of all customers |
To import the EXAMPLE APIREST collection into Postman, click here.
DB_HOST: The hostname or IP address of the database server.
DB_PORT: The port number that the database server is listening on.
DB_USER: The username that should be used to connect to the database.
DB_PASSWORD: The password that should be used to connect to the database.
DB_NAME: The name of the database to connect to.
MYSQL_ROOT_PASSWORD: The root password for the MySQL server. This is used to create and manage other user accounts.
MYSQL_DATABASE: The name of the database to be created and used by the application.
MYSQL_USER: The name of the user to be created and used by the application to access the database.
MYSQL_PASSWORD: The password for the MYSQL_USER account. This should be a strong, unique password.
DB_HOST=dbapi
DB_PORT=3306
DB_USER=myuser
DB_PASSWORD=mypassword
DB_NAME=mydatabase
MYSQL_ROOT_PASSWORD=my-secret-pw
MYSQL_DATABASE=mydatabase
MYSQL_USER=myuser
MYSQL_PASSWORD=mypassword
version: "3.8"
services:
myapp:
container_name: myapp
image: cnsoluciones/myapp
ports:
- 8080:8080
env_file:
- .env
depends_on:
dbapi:
condition: service_healthy
restart: unless-stopped
dbapi:
container_name: dbapi
image: mysql:8.0
env_file:
- .env
volumes:
- ./user-data/db:/var/lib/mysql
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
Here's the link to the apirest directory on GitHub: here.
Content type
Image
Digest
sha256:9a3c2fcb4…
Size
2.3 MB
Last updated
about 3 years ago
docker pull cnsoluciones/myapp