Giter Club home page Giter Club logo

go-boot's Introduction

Description

It is a simple web template project, which is written in Go with popular go frameworks. It uses these frameworks. Gin/ Logrus/ Gqlgen/ Oauth2, OIDC, Casbin, GoReleaser

This template shows how to use RestAPI, Graphql, Oauth2, Authentication, Authorization, Database Connection, and build and packaging.

It will build and package in Docker Image. You can configure
.goreleaser.yaml file for further build and package automation.

Prepare Running environment

brew install goenv goreleaser
goenv install 1.20.1
goenv global 1.20.1
git clone [email protected]:gogo-boot/go-boot.git
cd go-boot && go mod tidy && go run .

Configuration

Web Application

you can configure the web application.

vi platform/config/config.yml

Casbin Policy

vi platform/config/authz_model.conf
vi platform/config/authz_policy.csv

Go Releaser

you can configure the releaser

vi .goreleaser.yaml

Build

go build .

Deployment

Deployment test

goreleaser release --clean --snapshot --skip-publish

Deployment on Prod. you need to set a GitHub token

export GITHUB_TOKEN=xxxxxx
git tag 0.0.1
goreleaser release --clean

Running

docker run -p 8080:8080 gogo-boot/go-boot 

Source code start point

you can start review from main.go file and follow further for more detail.

Update Dependencies and organize dependencies

This uses several frameworks. RestAPI, Graphql, Oauth2, GORM... If you don't need of it, you can delete the directory and update main.go file.

go get -u
go mod tidy

then the unused framework will be removed and the build package will be slimmer.

Feature

  • Health check endpoint
  • Server-Side Events
  • HTML Template
  • Rest API
    • OpenAPI
    • GraphQL
  • Logging in Json Format
  • Security
    • Oauth2
    • OIDC
    • User Authorization
  • Configuration
  • Multi architect build
  • Dockerizing

Generate OpenAPI Code

# Install by npm
# npm install @openapitools/openapi-generator-cli -g
# Install by brew
# brew install openapi-generator
  
curl -O https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml
openapi-generator-cli generate -i petstore.yaml -g go-gin-server -o ./opeapi-gen \
--global-property=apiDocs=false,modelDocs=false \
--additional-properties=apiPath=openapi,packageName=openapi
set -o allexport
source test.env
set +o allexport
./dist/go-boot_darwin_amd64_v3/go-boot

adjust router group in the main.go file.

Http Endpoints & Integration Test

you can open *.http files with IntelliJ and send http request or test by clicking without typing

Roadmap

  • DB Connection
  • Implement OIDC Logout
  • Add Unit Test
  • CICD automation
  • Refactorings
  • Documentation
  • Publish Metrics
  • Release 1.0

Reference

If you like to change configuration or extend it, you can read further document below.

Gin Web Framework

Go Graphql Framework / gqlgen

Authorization Code Flow

Authorization Code Flow with Proof Key for Code Exchange (PKCE)

OIDC Best Practice

Go Authentication Framework / OAuth2 for Go

Go Authentication Framework / Go OIDC

Go Authorization Framework / Casbin

Go build/packaging manager / GoReleaser

Go Config

Logrus Logging

Casbin Access Control Model

Conventional Commits

go-boot's People

Contributors

gogo-boot avatar dependabot[bot] avatar

Watchers

 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.