Skip to content

anwar-arif/go-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go rest api

Run on local

Pre-requisites

  • redis server running at port 6379
  • mongodb server running at port 27017

Build application binary

$ ./build.sh
or
$ make build

Run application binary (run server)

$ go-rest-api serve-rest -c local.config.yml --env=local
or
$ make run

unit test

$ go test $(go list ./... | grep -v go-rest-api/e2e_test) -v

end to end test

  • run test server
$ ./build.sh && go-rest-api serve-rest --config test.config.yml --env=test
or 
$ make test-server
  • in seperate terminal window run the test suites
$ go test ./e2e_test --config=../test.config.yml -ginkgo.v --env=test
or 
$ make run-tests 

Run on Container

$ docker-compose -f docker-compose-dev.yml up --build
or
$ make serve-container

Run on local kubernetes cluster

Steps are described in k8s.README.md file

Folder structure

  • api folder contains rest controllers, middlewares
  • cmd folder contains application's base like main files
  • config folder contains app configuration files
  • e2e_test folder contains end-to-end testing suits
  • infra contains drivers like db, messaging, cache etc
  • repo folder contains database code
  • model folder contains model
  • service folder contains application service

flow

cmd -> api -> service -> repo, models, cache, messaging

Example APIS

Health

Method: GET URL: http://{base_url}:{system_server_port}/system/v1/health/api

Response: status_code: 200

{
    "data": "ok"
}

API list

Method: GET URL: http://localhost:8000 Response: status_code: 200

{
  "message": "success",
  "data": {
    "method": "GET",
    "service_name": "Go rest api"
  }
}

About

A REST api template using Golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages