Skip to content

A proof of concept Go API using Gin, GORM, taskq, GoDotEnv, and email

License

Notifications You must be signed in to change notification settings

thtg88/go-demo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Demo API

This project is a proof of concept to understand the Go (Golang) ecosystem.

Endpoints

Show User

GET /users/:id

Return a user from a given ID.

Response

{
    "Resource": {
        "ID": 1233,
        "FirstName": "John",
        "LastName": "Smith",
        "Email": "john.smith@acme.com",
        "RoleID": 1,
        "CreatedAt": "2020-10-11T17:57:50Z",
        "UpdatedAt": "2020-10-11T17:57:50Z",
        "Role": {
            "ID": 1,
            "Name": "User"
        }
    }
}

If a user is not found the following response is returned:

{
    "Errors": {
        "NotFound": [
            "User not found."
        ]
    },
    "Message": "There was a problem processing your request"
}

Create Contact Request

Send an email based on environment variable. The email is placed on a queue to be send by a worker.

Response

{
    "Success": true
}

Technologies Used

This module uses the following Go packages:

  • Gin: for HTTP routing and middlewares
  • GORM: ORM
  • taskq: for async job processing via Redis
  • GoDotEnv: for loading env variables from an .env file
  • email: to send email via SMTP

About

A proof of concept Go API using Gin, GORM, taskq, GoDotEnv, and email

Topics

Resources

License

Stars

Watchers

Forks