bgin

package module
v0.0.0-...-525798f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 7 Imported by: 0

README

bgin

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

bgin 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 bgin.

Installation

To install bgin 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 bgin.
$ go get -u github.com/foursking/bgin
  1. Import it in your code:
import "github.com/foursking/bgin" 

Quick start

package main

import (
	"fmt"
	"github.com/foursking/bgin"
	"github.com/foursking/bgin/consts"
	"github.com/foursking/bgin/handler"
	"github.com/foursking/bgin/helper/config"
	"github.com/foursking/bgin/middleware"
	"github.com/foursking/bgin/option"
	"github.com/gin-gonic/gin"
	"demo/route"
)

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 := bgin.New(
		option.WithMode(consts.DevMode),
		option.WithSignSecretKey("#$%1234"),
	)

	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

bgin 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

bgin 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

bgin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App() *types.App

func New

func New(options ...option.App) *types.App

Types

This section is empty.

Directories

Path Synopsis
helper

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL