mjh-go-rest

command module
v0.0.0-...-153da20 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

GO sample rest application

Features, concepts:

  • authentication
  • CRUD + DB connection (mongodb)
  • HTTP routing (mux)
  • logging
  • goroutines
  • channels
Google Cloud services used
  • Google Cloud Storage
  • Google Cloud PubSub

How to use

Clone repository
git clone https://github.com/mj-hagonoy/mjh-go-rest.git
cd mjh-go-rest
Update config file

Refer to config.yaml

host: "localhost"
port: 8080
database: 
  host: "0.0.0.0"
  port: 27017
  username: ""
  password: ""
  dbname: "mjh"
  sslmode: "disable"
directory:
  import_users: "<upload directory for csv files - import users>"
  mail_templates: <email templates directory>"
mail:
  from: "...@gmail.com"
  smtp_host: "smtp.mailtrap.io"
  smtp_port: "2525"
  smtp_user : "<user>"
  smtp_pwd: "<pwd>"
log:
  log_dir: "<log directory>"
file_storage:
  default: "google_cloud"
  google_cloud:
    project_id: "<gcp project ID>"
    bucket_name: "<gcp bucket name>"
    upload_path: "<upload path = [empty or subfolder]>"
credentials:
  google_app_creds : "<file path to GOOGLE_APPLICATION_CREDENTIALS>"
messaging:
  google_cloud: 
    project_id: "<gcp project ID>"
    topic_id: "<gcp bucket name>"
Build
go build ./main.go
Run web service
./main --config config.yaml --type web
Run job service
./main --config config.yaml --type job
Run email service
./main --config config.yaml --type email

APIs

API Method Request Body Response Description
/api/v1/users/import POST file : csv file (json) batch job info [id, status] accepts csv file with users info [first name, last name, email]
/api/v1/users GET (json) users returns a list of users
/api/v1/jobs/:id GET (json) job info returns information of the job indicated by id

TODO

  • docker container
  • db initialization scripts

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
db
job

Jump to

Keyboard shortcuts

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