MIT License

项目介绍

gogearbox/gearbox 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 MIT License 许可证,目前获得 805 个 Star、55 次 Fork。

仓库全名
gogearbox/gearbox
开源许可证
MIT License
Star 数
805
Fork 数
55
未关闭 Issue
1

README 摘要

gearbox :gear: 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 faster than net/http gearbox seeks to be Secure :closedlockwithkey: Fast :rocket: Easy to use :eyeglasses: Lightweight Supported Go versions & installation :gear: gearbox requires version 1.14 or higher of Go (Download Go) Just use go get to download and install…

完整内容见 GitHub 原始 README 或本页 。

常见问题

gearbox 用什么语言开发?

主要使用 Go 编写,采用 MIT License 许可证,目前有 805 个 Star。

gearbox 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 gearbox 的源码?

可以直接克隆仓库:git clone https://github.com/gogearbox/gearbox.git,默认分支为 master;安装与运行步骤见仓库 README。

gearbox 最近还在维护吗?

仓库最近一次更新为 1月6日,当前有 1 个未关闭 Issue;Star 数为 805,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Gearbox :gear: is a web framework written in Go with a focus on high performance

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
930
价值分
500
活跃状态
活跃

语言占比

Go

Release

README


DeepSource

gearbox :gear: 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 faster than net/http

gearbox seeks to be

  • Secure :closed_lock_with_key:
  • Fast :rocket:
  • Easy to use :eyeglasses:
  • Lightweight

Supported Go versions & installation

:gear: gearbox requires version 1.14 or higher of Go (Download Go)

Just use go get to download and install gearbox

go get -u github.com/gogearbox/gearbox

Examples

package main

import (
	"github.com/gogearbox/gearbox"
)

func main() {
	// Setup gearbox
	gb := gearbox.New()

	// Define your handlers
	gb.Get("/hello", func(ctx gearbox.Context) {
		ctx.SendString("Hello World!")
	})

	// Start service
	gb.Start(":3000")
}
Parameters
package main

import (
	"github.com/gogearbox/gearbox"
)

func main() {
	// Setup gearbox
	gb := gearbox.New()

	// Handler with parameter
	gb.Get("/users/:user", func(ctx gearbox.Context) {
		ctx.SendString(ctx.Param("user"))
	})

	// Start service
	gb.Start(":3000")
}
Middlewares
package main

import (
	"log"

	"github.com/gogearbox/gearbox"
)

func main() {
	// Setup gearbox
	gb := gearbox.New()

	// create a logger middleware
	logMiddleware := func(ctx gearbox.Context) {
		log.Printf("log message!")

		// Next is what allows the request to continue to the next
		// middleware/handler
		ctx.Next()
	}

	// create an unauthorized middleware
	unAuthorizedMiddleware := func(ctx gearbox.Context) {
		ctx.Status(gearbox.StatusUnauthorized)
			.SendString("You are unauthorized to access this page!")
	}

	// Register the log middleware for all requests
	gb.Use(logMiddleware)

	// Define your handlers
	gb.Get("/hello", func(ctx gearbox.Context) {
		ctx.SendString("Hello World!")
	})

	// Register the routes to be used when grouping routes
	routes := []*gearbox.Route{
		gb.Get("/id", func(ctx gearbox.Context) {
			ctx.SendString("User X")
		}),
		gb.Delete("/id", func(ctx gearbox.Context) {
			ctx.SendString("Deleted")
		}),
	}

	// Group account routes
	accountRoutes := gb.Group("/account", routes)

	// Group account routes to be under api
	gb.Group("/api", accountRoutes)

	// Define a route with unAuthorizedMiddleware as the middleware
	// you can define as many middlewares as you want and have
	// the handler as the last argument
	gb.Get("/protected", unAuthorizedMiddleware, func(ctx gearbox.Context) {
		ctx.SendString("You accessed a protected page")
	})

	// Start service
	gb.Start(":3000")
}
Static Files
package main

import (
	"github.com/gogearbox/gearbox"
)

func main() {
	// Setup gearbox
	gb := gearbox.New()

	// Serve files in assets directory for prefix static
	// for example /static/gearbox.png, etc.
	gb.Static("/static", "./assets")

	// Start service
	gb.Start(":3000")
}

Benchmarks

  • CPU 3.1 GHz Intel Xeon® Platinum 8175M (24 physical cores, 48 logical cores)
  • MEMORY 192GB
  • GO go 1.14.6 linux/amd64
  • OS Linux

For more results, check Our Docs

Contribute & Support

Check Our Docs for more information about gearbox and how to contribute

Sponsors

Organizations that are helping to manage, promote, and support Gearbox :gear:

trella: A B2B technology platform and trucking
marketplace that connects shippers with carriers

Who uses Gearbox

Gearbox :gear: is being used by multiple organizations including but not limited to

Contributors

Get in touch!

Feel free to chat with us on Discord, or email us at [email protected] if you have questions, or suggestions

License

gearbox is licensed under MIT License

Logo is created by Mahmoud Sayed and distributed under Creative Commons License

Third-party library licenses

评论

暂无评论