Giter Site home page Giter Site logo

vigneshuvi / go-micro-service Goto Github PK

View Code? Open in Web Editor NEW
7.0 0.0 0.0 6.57 MB

Simple Golang Micro Manager is useful to create RestFul web services using Golang.

Go 63.99% CSS 8.97% HTML 20.11% JavaScript 6.94%
golang-micro-manager golang micro-service middleware-golang middleware api-versioning golang-coverage golang-coverage-profile

go-micro-service's Introduction

Go-Micro-Service

Simple Golang Micro Manager is useful to create RestFul web services using Golang.

Features:

  1. Environment setup (Like Development, QA, Production)
  2. API Versioning
  3. Middleware Authentication Layer
  4. Supports for HTTP request methods (GET, PUT, POST, DELETE)
  5. Host Web Pages
  6. Code Coverage (Unit testing)

1. Environment setup

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"
}

2. API Version

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>        

3. Middleware Authentication Layer

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.

4. Supports for HTTP request methods (GET, PUT, POST, DELETE)

Go Micro Service Manager helps to support the four types of HTTP request methods.

5. Host Web pages

Go Micro Service Manager helps to host static web pages in the HTTP server with dynamic web title based on the environments.

alt text

How to run this Go Micro Services server?

  • 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)

alt text

How to run unit test and see the code coverage?

  • 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

alt text

How to test the RESTful web service?

  • 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 it?

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

alt text

go-micro-service's People

Contributors

vigneshuvi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.