restfulapi

command module
v0.0.0-...-723eb5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

RestfulAPI

Esta API está escrita en GO y responde a peticiones que se le envian, la aplicación es totalmente RESTful, hace uso de una base de datos MySQL y un ORM.

Herramientas usadas

Configuración

  • configuration.json
{
    "server": "localhost",
    "port": "3306",
    "user": "root",
    "password": "root",
    "database": "go_rest"
}

Se tiene un archivo para la configuración de la base de datos, la configuración predeterminada corresponde a la dirección 127.0.0.1:3306

Base de datos

La cual tiene una estructura:

La tabla no hace falta crearla porque se migra desde la aplicación

  • db.AutoMigrate(&user{})

Compilación y ejecución

  • Con Docker

Con docker sólo hace falta escribir 2 comandos:

  • $ sudo docker build -t my-golang-app .
  • $ sudo docker run -it -p 5000:5000 my-golang-app

Y se desplegara la aplicación corriendo en el puerto 5000

  • Sin Docker(Windows o mac)

Primero se debe crear una carpeta llamada TheGolurk que corresponde a la del proyecto, luego pegar el repositorio allí y por ultimo descargar todas las herramientas con el administrador de paquetes de go

  • El Workspace empieza desde: C:/go/src/github.com

  • $ mkdir TheGolurk

  • $ cd TheGolurk

  • $ git clone https://github.com/TheGolurk/RestfulAPI.git

  • $ go get -u github.com/labstack/echo/...

  • $ go get -u github.com/jinzhu/gorm

  • $ go get -u github.com/go-sql-driver/mysql

  • Sin compilar $ go run main.go

  • Compilado y ejecutado $ go build main.go

    $ ./main

    Al final tanto en windows, docker o mac se deberá mirar la presentación del framework y su puerto

Peticiones

  • GET (Traer a un solo usuario)

  • GET (Traer todos)

  • POST (Crear un usuario)

  • PUT (Actualizar un usuario)

  • DELETE (Eliminar un usuario)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL