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

Overview

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

    bug 
    opened by sriio 3
  • 怎样实现非单例注入

    怎样实现非单例注入

    您好,在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
    question 
    opened by crcms 2
  • 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

    opened by clarechu 2
  • 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

    bug 
    opened by john-deng 2
  • 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.

    dependencies 
    opened by dependabot[bot] 1
  • 配置文件关闭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()

    opened by twdp 1
  • 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"
    }
    
    opened by john-deng 1
  • 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.

    opened by filipecosta90 0
  • 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

    bug 
    opened by john-deng 0
  • 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

    enhancement 
    opened by john-deng 0
Releases(v1.6.4)
  • v1.6.4(Oct 26, 2022)

  • v1.6.3(May 23, 2022)

  • v1.6.2(Apr 26, 2022)

  • v1.6.0(Jun 13, 2021)

    Release notes,

    • Added at.SchedulingEnabled and at.Scheduled annotation and its implementations.
    • Fixes the issue that runtime instance does not handle concurrency well
    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(Mar 17, 2022)

  • v1.5.0(Mar 7, 2021)

  • v1.4.0(Jul 22, 2020)

    Release notes

    • Added annotation at.RequiresPermissions and its examples in middleware
    • Support to get method annotation from hiboot web application context
    • Clean up unite tests
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Jan 9, 2020)

  • v1.3.0(Oct 10, 2019)

    Release Notes

    • Implemented annotation v2 which is supported via struct.
    • Implemented Middleware via at.Middleware and at.MiddlewareHandler.
    • Implemented Swagger 2.0 and its annotations.
    • Reimplemented property builder, the priority will be
      1. Command line arguments
      2. Environment variables
      3. External configuration file in working directory ( $WORK_DIR/config/applicaton.yml)
      4. External configuration file with active profile name as postfix ($WORK_DIR/config/applicaton-${app.profiles.active}.yml)
      5. Calling application method SetProperty()
      6. Default value that injected by Hiboot via tag default
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Aug 24, 2019)

    Release notes

    • Refactored annotation, all annotations now inherit from at.Annotation

    e.g. annotation at.RestController inherit from at.Annotation

    // RestController is the annotation that declare current controller is the RESTful Controller
    type RestController struct {
    	Annotation
    }
    
    • Removed annotation at.Path, for request mapping, a value will be injected, no extra at.Path is needed, e.g. a value:"/{id:int}/and/{name}" will be injected to annotation at.GetMapping
    func (c *UserController) GetUserByPathVariable(at struct{ at.GetMapping `value:"/{id:int}/and/{name}"` }, 
            id int, name string) (response *UserResponse, err error) {
    
    	// TODO: add your business logic here
    
    	return
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Aug 7, 2019)

    Release Notes

    • Support customized server context path, it can be configured in config fileapplication.yml

    e.g.

    server:
      context_path: /my-app
    
    • Support customized HTTP router annotations at.RequestMapping, at.GetMapping, at.PostMapping, at.PutMapping, at.DeleteMapping, at.Method, and at.Path, see here for more details
    
    type UserController struct {
    	// at.RestController or at.RestController must be embedded here
    	at.RestController
    
    	// then Hiboot will inject /user to UserController.RequestMapping
    	at.RequestMapping `value:"/user"`
    }
    
    func (c *UserController) Get(
    	id int,
    	name string,
    	at struct{at.GetMapping; at.Path `value:"/{id:int}/and/{name}"`},
    ) (response *UserResponse, err error) {
    
    	// response
    	response = new(UserResponse)
    	// TODO: implement business logic
    	return
    }
    
    • Added Ping and Pong callback to WebSocket handler
    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Jul 23, 2019)

  • v1.1.0(Apr 27, 2019)

    Release Notes

    • Implemented jaeger starter and examples, now Hiboot supports open tracing
    • Added app.version property
    • Implemented default application property setter
    • Fixed the issue that default property does not work properly
    • Implemented HTTP client starter and added default HTTP client
    • Fixed the issue that request instance is reused which will cause failure on concurrent requests
    • Fixed the issue that log is disabled on go test.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Mar 12, 2019)

  • v1.0.3(Feb 11, 2019)

  • v1.0.2(Feb 9, 2019)

  • v1.0.1(Dec 10, 2018)

  • v1.0.0(Dec 5, 2018)

  • v0.11.2(Dec 4, 2018)

  • v0.11.1(Nov 27, 2018)

    Release Notes

    • fixes issue #51 that the property does not overwritten by the higher priority configurations.
    • fixes the regression issue that grpc server host should not be set as default
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Nov 21, 2018)

    Release Notes

    • refactored system.Builder
    • refactored app.Application
    • implemented context aware dependency injection though the controller's method
    • improved test coverage
    Source code(tar.gz)
    Source code(zip)
  • v0.10.4(Nov 8, 2018)

    Release Notes

    • added secured websocket example with jwt
    • refactored package grpc/mock to grpc/mockgrpc
    • fixed the issue that property setter failed sometimes
    Source code(tar.gz)
    Source code(zip)
  • v0.10.2(Nov 6, 2018)

  • v0.10.1(Nov 5, 2018)

  • v0.10.0(Nov 2, 2018)

    Release Notes

    • Support vanity import, the source code will be relocated from $GOPATH/src/github.com/hidevopsio/hiboot to $GOPATH/src/hidevops.io/hiboot
    // Changed import from github.com/hidevopsio/hiboot
    import "github.com/hidevopsio/hiboot/pkg/app/web"
    
    
    // To hidevops.io/hiboot
    import "hidevops.io/hiboot/pkg/app/web"
    
    
    Source code(tar.gz)
    Source code(zip)
  • v0.9.9(Oct 31, 2018)

    Release Notes

    • Added websocket starter
    • Added custom property, now Hiboot will accept application property setter or property that passed from command line argument with --, e.g. my-hiboot-app --server.port=8081
    Source code(tar.gz)
    Source code(zip)
  • v0.9.8(Oct 27, 2018)

  • v0.9.7(Oct 25, 2018)

    Release Notes

    • refactored app.Register(), deprecated app.Component(), app.AutoConfiguration(), web.RestController(). now app.Register() will be the only one register function.
    • enhanced controller and auto configuration.
    Source code(tar.gz)
    Source code(zip)
  • v0.9.6(Oct 23, 2018)

    Release Notes

    • refactor cli.Application, added cli.RootCommand and cli.SubCommand
    • fixes the issue that jwt controller does not handle null jwt field.
    • add at.Qualifier annotation
    • fixes the issue that the package cmd of examples/cli/crypto is not imported
    Source code(tar.gz)
    Source code(zip)
  • v0.9.5(Oct 17, 2018)

henrylee2cn 1.6k Nov 18, 2022
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

GoFrame 8.5k Nov 20, 2022
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. 中文

dragon 8 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

azerothyang 0 Sep 6, 2022
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

astaxie 568 Nov 18, 2022
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

LabStack LLC 24.2k Nov 20, 2022
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

Gearbox 687 Nov 12, 2022
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

Gearbox 688 Nov 28, 2022
High performance, simple Go web framework

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

Tree Xie 60 Nov 13, 2022
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

beego Framework 29.2k Nov 28, 2022
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

wjp 350 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

Gookit 83 Oct 3, 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 Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 327 Nov 13, 2022
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

Krisna Pranav 13 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

null 22 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

golanger 298 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

null 8 Jul 14, 2022
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

Macaron 3.3k Nov 17, 2022
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

Kamaleshwar 261 Nov 20, 2022