Simple Golang Micro Manager is useful to create RestFul web services using Golang.
- Environment setup (Like Development, QA, Production)
- API Versioning
- Middleware Authentication Layer
- Supports for HTTP request methods (GET, PUT, POST, DELETE)
- Host Web Pages
- Code Coverage (Unit testing)
Web Service basics have to support multiple environments like development, QA, Production environment and Configured in the generic format. Under environments folder created three different config files to achieve the Environment setup.
{
"title" : "Golang Micro Web Service Manager (DEV)",
"version" : "v1",
"http": {
"enable" : true,
"port" : 3000
},
"https": {
"options" : {
"key" : null,
"cert" : null
},
"enable" : false,
"port" : 3043
},
"auth" : "bypass"
}
Configure the API version number based on the environments JSON file.
E.g., DEV.json
is helpful achieve the API versioning to register web services based on the version number.
http://<webserver>/<version>/<webservice>
Every RESTful Web services need the security and validation before going to hit the server business logic's. Go Micro Service Manager helps to implement the basic security and validate the request headers.
For the different environments, We can able to provide a different kind of security implementation using over security implementation.
- DEV environment is by-pass the security validation.
- QA and Production environments are required the security validation.
If it's QA and Production environments, Request Header must be.
- authorization = "bybass"
- content-type = "application/json"
- date = "1454577924104" - UTC time.
Go Micro Service Manager helps to support the four types of HTTP request methods.
Go Micro Service Manager helps to host static web pages in the HTTP server with dynamic web title based on the environments.
- Need to install Go & Set the GOPATH
- Open terminal and check the Go version
- Run the Go HTTP server by
go run main.go DEV
command (Like DEV, QA and PROD)
- Open terminal and move to Go-Micro-Service folder
- Run
go test ./... -coverprofile=coverage.out
to generate coverage profile - Seeing coverage output in html file use
go tool cover -html=coverage.out
-
If you set up the node environment is
DEV
, then you can directly test it from RESTful Client.http://localhost:3000/v1/user - Show All - Fetch all based on request. http://localhost:3000/v1/user?id="test" - Show - Fetch based on request id. http://localhost:3000/v1/user?id="test" - PUT - Update based on request id. http://localhost:3000/v1/user - POST - Create based on request. http://localhost:3000/v1/user:id="test" - DELETE - Update based on request id.
Do you like this repo? Share it on Twitter, Facebook, Google+ or anywhere you like so that more of us can use it and help. Thanks!
Created by Vignesh