Skip to content
/ goapi.g8 Public template

Go template for microservices using Echo framework.

License

Notifications You must be signed in to change notification settings

btnguyen2k/goapi.g8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goapi.g8

Giter8 template to develop API server / Microservices in Go using Echo framework.

Latest release: template-v0.4.r4.

Features

Getting Started

Install go-giter8

This a Giter8 template, so it is meant to be used in conjunction with a giter8 tool. Since this is a template for Go application, it make sense to use go-giter8.

See go-giter8 website for installation guide.

Create new project from template

g8 new btnguyen2k/goapi.g8

and follow the instructions.

Note: This template requires go-giter8 version 0.3.2 or higher.

Application configurations

Application configurations are loaded from config/application.conf file, in HOCON format. Its content is human-readable and self-explained. So, this readme lists only key configurations:

application info

app {
  # this section configures application's info such as name, version, description, etc.
}

API configurations

api {
  # "api" section configure common API settings swuch as max request size or request timeout

  http {
    # this sub-section configures HTTP/Rest API gateway
  }

  grpc {
    # this sub-section configures gRPC API gateway
  }
}

API endpoints

api.http.endpoints {
  # this sub-section defines API HTTP endpoints
}

Implement APIs

General guideline

  • Each API is an itineris.IApiHandler instance (e.g. func(*ApiContext, *ApiAuth, *ApiParams) *ApiResult)
  • Register APIs with the global API router instance goapi.ApiRouter
  • (Optional) Define API HTTP endpoints in configuration api.http.endpoints sub-section.

If gRPC API gateway is enable, APIs are automatically available via gRPC. See gRPC service definition file.

Sample APIs:

API filter

API filter (instance of type itineris.IApiFilter) is plugable component that is used to intercept API call and do some pre-processing, intercept result and do some post-processing before returning to caller.

See sample API filter.

Scaffolding

At project's root directory, run command

$ g8 scaffold <scaffold-name>

to generate scaffolds. This template includes a few scaffolds.

Scaffolding requires go-giter8 v0.4.0 or higher.

LICENSE & COPYRIGHT

See LICENSE.md for details.

Giter8 template

For information on giter8 templates, please see http://www.foundweekends.org/giter8/