hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework

hiboot

Build Status

About

Hiboot is a cloud native web and cli application framework written in Go.

Hiboot is not trying to reinvent everything, it integrates the popular libraries but make them simpler, easier to use. It borrowed some of the Spring features like dependency injection, aspect oriented programming, and auto configuration. You can integrate any other libraries easily by auto configuration with dependency injection support.

If you are a Java developer, you can start coding in Go without learning curve.

Overview

  • Web MVC (Model-View-Controller).
  • Auto Configuration, pre-create instance with properties configs for dependency injection.
  • Dependency injection with struct tag name `inject:""`, Constructor func, or Method.

Getting Started

Community Contributions Guide

Thank you for considering contributing to the Hiboot framework, The contribution guide can be found here.

License

© John Deng, 2017 ~ time.Now

Released under the Apache License 2.0

Comments
  • Can't use Go 1.11 module

    Can't use Go 1.11 module

    Describe the bug As hiboot use a fork of Viper, the imports (github.com/hidevopsio/viper) does not correspond to the module name (module github.com/spf13/viper in go.mod)

    go: hidevops.io/[email protected]: parsing go.mod: unexpected module path "github.com/spf13/viper"
    go: error loading module requirements
    

    Expected behavior Use directly the repo github.com/spf13/viper or change the module name of github.com/hidevopsio/viper

    Steps to reproduce the bug

    cd $GOPATH/src/github.com/hidevopsio/
    git clone https://github.com/hidevopsio/hiboot-web-app-demo
    cd hiboot-web-app-demo
    GO111MODULE=on go mod init github.com/hidevopsio/hiboot-web-app-demo
    GO111MODULE=on go build -v
    

    Version V0.11.1

    Environment Archlinux Go 1.11.2

  • 怎样实现非单例注入

    怎样实现非单例注入

    您好,在main函数中有如下代码结构

    
    // Controller Rest Controller with path /
    // RESTful Controller, derived from web.Controller. The context mapping of this controller is '/' by default
    type Controller struct {
    	// at.RestController or web.Controller must be embedded here
    	at.RestController
    
    	repository *Repository
    }
    
    type Repository struct {
    	Name string
    }
    
    // Get GET /
    // Get method, the context mapping of this method is '/' by default
    // the Method name Get means that the http request method is GET
    func (c *Controller) Get(repository *Repository) string {
    	// response
    	return "My first Hiboot web application,Name" + repository.Name
    }
    
    func NewRepository() *Repository {
    	return &Repository{strconv.Itoa(rand.Intn(99))}
    }
    
    func newController(repository *Repository) *Controller {
    	return &Controller{
    		repository:repository,
    	}
    }
    
    func main()  {
    	
    	web.NewApplication(newController,NewRepository).
    		SetProperty(app.ProfilesInclude, actuator.Profile, logging.Profile).
    		Run()
    }
    

    当我在NewApplication注册了NewRepository方法时,Repository可以在Controller中注入 但很遗憾这却变成了一个单例模式的Repository,于是产生子两个问题

    1. Reposiotry 是否必须要注册(目前测试不注册,没法反射,也就是前提必须是Register中)
    2. 如果让Repository在每次路由请求的时候,不使用单例,需要每次实例化新的struct
  • application-local.yml 不能覆盖原本的环境变量

    application-local.yml 不能覆盖原本的环境变量

    Describe the bug {{ Succinctly describe the bug }} 我的环境变量 为local The following profiles are active: local, [jwt grpc etcd kube mio locale docker websocket gorm bolt web] image 我想覆盖默认的环境配置,但是并没有覆盖掉原来的值 Expected behavior {{ What did you expect to happen? }} 我需要application-local.yml 覆盖application-gorm.yml 里面的host参数,来调节不通的环境。

    Steps to reproduce the bug {{ Minimal steps to reproduce the behavior }}

    Version {{ What version of Hiboot are you using? }} v0.11.0 Environment {{ Which environment, cloud vendor, OS, etc are you using? }} macos 10.13

  • Some unit test is not passing on Windows.

    Some unit test is not passing on Windows.

    Describe the bug Some unit test is not passing on Windows.

    Expected behavior Should pass all unit tests

    Steps to reproduce the bug git clone the repo and run go test

    go test
    

    Version v0.9.3

    Environment Windows 10

  • Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8

    Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8

    Bumps gopkg.in/yaml.v2 from 2.2.4 to 2.2.8.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

  • 配置文件关闭actuator, 但是他的controller注册了,这关闭有啥用?

    配置文件关闭actuator, 但是他的controller注册了,这关闭有啥用?

    在配置文件中profiles.include列表中删除, 提示已经被过滤掉,但是他的controller /health依然会注册进来。

    [WARN] 2020/02/26 17:08 Auto configuration actuator is filtered out! Just ignore this warning if you intended to do so. [INFO] 2020/02/26 17:08 Auto configuration logging is configured on logging.configuration. [INFO] 2020/02/26 17:08 Mapped GET "/health" onto actuator.healthController.Get()

  • Middleware

    Middleware

    Implemented middleware with annotation support

    implement HiBoot middleware

    
    type fakeConditionalJwtMiddleware struct {
    	at.Middleware
    	at.UseJwt
    }
    
    func newConditionalFakeJwtMiddleware() *fakeConditionalJwtMiddleware {
    	return &fakeConditionalJwtMiddleware{}
    }
    
    // CheckJwt
    func (m *fakeConditionalJwtMiddleware) CheckJwt(at struct{ at.MiddlewareHandler
    }, ctx context.Context)  {
    	log.Debug("fakeConditionalJwtMiddleware.CheckJwt()")
    	if ctx.URLParam("token") == "" {
    		ctx.StatusCode(http.StatusUnauthorized)
    		return
    	}
    	ctx.Next()
    	return
    }
    

    Use HiBoot Middleware

    
    type jwtAuthTestController struct {
    	at.RestController
    	at.UseJwt
    	at.RequestMapping `value:"/jwt-auth" `
    }
    
    func newJwtAuthTestController() *jwtAuthTestController {
    	return &jwtAuthTestController{}
    }
    
    // Get
    func (c *jwtAuthTestController) Get(at struct{ at.GetMapping `value:"/"` }) string {
    	return "Get from jwt auth test controller"
    }
    
    // Delete
    func (c *jwtAuthTestController) Delete(at struct{ at.DeleteMapping `value:"/"` }) string  {
    	return "Delete from jwt auth test controller"
    }
    

    or use it on specific method

    
    type jwtAuthTestController struct {
    	at.RestController
    	at.RequestMapping `value:"/jwt-auth" `
    }
    
    func newJwtAuthTestController() *jwtAuthTestController {
    	return &jwtAuthTestController{}
    }
    
    // Get
    func (c *jwtAuthTestController) Get(at struct{ at.GetMapping `value:"/"` }) string {
    	return "Get from jwt auth test controller"
    }
    
    // Delete this method only allowed authenticated user to operate
    func (c *jwtAuthTestController) Delete(at struct{ 
    	at.DeleteMapping `value:"/"`
    	at.UseJwt
    }) string  {
    	return "Delete from jwt auth test controller"
    }
    
  • codahale/hdrhistogram repo url has been transferred under the github HdrHstogram umbrella

    codahale/hdrhistogram repo url has been transferred under the github HdrHstogram umbrella

    Problem

    The codahale/hdrhistogram repo has been transferred under the github HdrHstogram umbrella with the help from the original author in Sept 2020 (new repo url https://github.com/HdrHistogram/hdrhistogram-go). The main reasons are to group all implementations under the same roof and to provide more active contribution from the community as the original repository was archived several years ago.

    The dependency URL should be modified to point to the new repository URL. The tag "v0.9.0" was applied at the point of transfer and will reflect the exact code that was frozen in the original repository.

    If you are using Go modules, you can update to the exact point of transfer using the @v0.9.0 tag in your go get command.

    go mod edit -replace github.com/codahale/hdrhistogram=github.com/HdrHistogram/[email protected]
    

    Performance Improvements

    From the point of transfer, up until now (mon 16 aug 2021), we've released 3 versions that aim support the standard HdrHistogram serialization/exposition formats, and deeply improve READ performance. We recommend to update to the latest version.

  • app crashes during load test

    app crashes during load test

    Describe the bug app crashes during load test

    fatal error: concurrent map writes
    github.com/hidevopsio/hiboot/pkg/factory/instantiate.(*instantiateFactory).SetInstance(0xc00080dcc0, 0xc001f72d68, 0x3, 0x3, 0x0, 0x0)
    

    Expected behavior should handle concurrent map access

    Steps to reproduce the bug load testing

    Version v1.6.0

    Environment Docker in Kubernetes

  • Should allow user to inject named dependency

    Should allow user to inject named dependency

    Describe the feature request Should allow user to inject named dependency

    jwtToken will not able to inject as the the injectable name in hiboot starter jwt is token, we need to accept alternative name as well, e.g. jwtToken.

    Describe alternatives you've considered\

    type loginController struct {
    	web.Controller
            // jwtToken will not able to inject as the the injectable name in hiboot starter jwt is token
    	jwtToken jwt.Token
    }
    
    func newLoginController(jwtToken jwt.Token) *loginController {
    	return &loginController{
    		jwtToken: jwtToken,
    	}
    }
    

    Additional context None

GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.

GoFrame English | 简体中文 GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang. If you're a

Jan 2, 2023
Dragon 🐲 🐲 🐲 is an enterprise high performance web framework with Go for the feature and comfortable develop.

Dragon start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfortable develop. 中文

Sep 14, 2022
Dragon 🐲 🐲 🐲 is a lightweight high performance web framework with Go for the feature and comfortable develop.

Dragon project new link start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfor

Sep 6, 2022
beego is an open-source, high-performance web framework for the Go programming language.
beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 1, 2023
High performance, minimalist Go web framework
High performance, minimalist Go web framework

Supported Go versions As of version 4.0.0, Echo is available as a Go module. Therefore a Go version capable of understanding /vN suffixed imports is r

Jan 2, 2023
Gearbox :gear: is a web framework written in Go with a focus on high performance
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Jan 3, 2023
Gearbox :gear: is a web framework written in Go with a focus on high performance
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Dec 29, 2022
High performance, simple Go web framework

Elton Elton的实现参考了koa以及echo,中间件的调整均为洋葱模型:请求由外至内,响应由内至外。主要特性如下: 处理函数(中间件)均以返回error的形式响应出错,方便使用统一的出错处理中间件将出错统一转换为对应的输出(JSON),并根据出错的类型等生成各类统计分析 成功响应数据直接赋值

Dec 17, 2022
beego is an open-source, high-performance web framework for the Go programming language.
beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 8, 2023
letgo is an open-source, high-performance web framework for the Go programming language.

high-performance Lightweight web framework for the Go programming language. golang web framework,高可用golang web框架,go语言 web框架 ,go web

Sep 23, 2022
⚡ Rux is an simple and fast web framework. support middleware, compatible http.Handler interface. 简单且快速的 Go web 框架,支持中间件,兼容 http.Handler 接口

Rux Simple and fast web framework for build golang HTTP applications. NOTICE: v1.3.x is not fully compatible with v1.2.x version Fast route match, sup

Dec 8, 2022
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Jan 5, 2023
A powerful go web framework for highly scalable and resource efficient web application

webfr A powerful go web framework for highly scalable and resource efficient web application Installation: go get -u github.com/krishpranav/webfr Exa

Nov 28, 2021
A powerful go web framework for highly scalable and resource efficient web application

A powerful go web framework for highly scalable and resource efficient web application

Oct 3, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

Nov 14, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

Jul 14, 2022
Package macaron is a high productive and modular web framework in Go.
Package macaron is a high productive and modular web framework in Go.

Macaron Package macaron is a high productive and modular web framework in Go. Getting Started The minimum requirement of Go is 1.6. To install Macaron

Jan 2, 2023
A minimal framework to build web apps; with handler chaining, middleware support; and most of all standard library compliant HTTP handlers(i.e. http.HandlerFunc).
A minimal framework to build web apps; with handler chaining, middleware support; and most of all standard library compliant HTTP handlers(i.e. http.HandlerFunc).

WebGo v4.1.3 WebGo is a minimalistic framework for Go to build web applications (server side) with zero 3rd party dependencies. Unlike full-fledged fr

Jan 1, 2023