Giter Site home page Giter Site logo

zyallers / zgin Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 197 KB

ZGin is a API framework written in Go (Golang). An MVCS, Restful, and version control framework based on the Gin framework. If you need performance and good productivity, you will love ZGin.

License: MIT License

Go 85.24% Shell 14.76%
zgin go golang server middleware framework httprouter performance mvc version-control

zgin's Introduction

zgin

Go Report Card MIT license Build Status Foundation GoDoc Sourcegraph Release TODOs goproxy.cn

Zgin is a API framework written in Go (Golang). An MVCS, Restful, and version control framework based on the Gin framework. If you need performance and good productivity, you will love zgin.

Installation

To install zgin package, you need to install Go and set your Go workspace first.

  1. The first need Go installed (version 1.11+ is required), then you can use the below Go command to install zgin.
$ go get -u github.com/ZYallers/zgin
  1. Import it in your code:
import "github.com/ZYallers/zgin" 

Quick start

package main

import (
	"fmt"
	"github.com/ZYallers/zgin"
	"github.com/ZYallers/zgin/consts"
	"github.com/ZYallers/zgin/example/route"
	"github.com/ZYallers/zgin/handler"
	"github.com/ZYallers/zgin/helper/config"
	"github.com/ZYallers/zgin/middleware"
	"github.com/ZYallers/zgin/option"
	"github.com/gin-gonic/gin"
)

func main() {
	gin.DisableConsoleColor()
	gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {}
	if err := config.ReadFile(); err != nil {
		panic(fmt.Errorf("read config file error: %s", err))
	}
	app := zgin.New(
		option.WithMode(consts.DevMode),
	)
	app.Run(
		handler.WithNoRoute(),
		handler.WithHealth(),
		middleware.WithZapRecovery(),
		middleware.WithZapLogger(),
		handler.WithExpVar(),
		handler.WithPrometheus(),
		handler.WithSwagger(),
		handler.WithPProf(),
		middleware.WithRestCheck(route.Restful),
	)
}

run main.go and visit http://0.0.0.0:9010/health (for windows "http://localhost:8080/health") on browser

$ go run main.go

Zgin v1.stable

  • MVCS four-tier architecture support
  • Restful interface style support
  • API version control and permission custom configuration
  • PProf middleware support
  • Prometheus middleware support
  • Swagger api docs middleware support
  • Graceful server shutdown and reload

Build with jsoniter

Zgin uses encoding/json as default json package but you can change to jsoniter by build from other tags.

$ go build -tags=jsoniter .

License

Released under the MIT License

zgin's People

Contributors

zyallers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

myvoyage

zgin's Issues

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.