Giter8 template to develop API server / Microservices
in Go using Echo framework.
Latest release: template-v0.4.r4.
- Create new project from template with go-giter8.
- API framework:
- JSON-encoded.
- Plugable filters, included built-in ones:
AddPerfInfoFilter
LoggingFilter
AuthenticationFilter
- REST API gateway built on top Echo Framework v4.
- gRPC API gateway (since template-v0.4.r2).
- Samples:
- Sample
.gitlab-ci.yaml
&Dockerfile
to package application as Docker image - Scaffolding (since template-v0.4.r2, require go-giter8
v0.4.0
or higher).
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.
g8 new btnguyen2k/goapi.g8
and follow the instructions.
Note: This template requires
go-giter8
version0.3.2
or higher.
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
}
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.
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.
See LICENSE.md for details.
For information on giter8 templates, please see http://www.foundweekends.org/giter8/