Gearbox

Gearbox ⚙️ is a web framework written in Go with a focus on high performance
Alternatives To Gearbox
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Fiber25,420656a day ago275September 08, 202241mitGo
⚡️ Express inspired web framework written in Go
Iris23,7943202 days ago212September 21, 202278bsd-3-clauseGo
The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :leaves: :rocket: | 谢谢 | #Go
Locust20,965
7 days ago41September 21, 202217mitPython
Write scalable load tests in plain Python 🚗💨
Fasthttp19,3056451,9572 days ago175September 03, 202269mitGo
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
Nginx Admins Handbook12,393
a year ago1mitShell
How to improve NGINX performance, security, and other important things.
Web Frameworks6,623
a day ago13April 27, 2021185mitPHP
Which is the fastest web framework?
Webserver5,970
18 days ago99mitC++
A C++ High Performance Web Server
Vibora5,639
2 years ago145mitPython
Fast, asynchronous and elegant Python web framework.
Jsdelivr4,819
a month ago18mitJavaScript
A free, fast, and reliable Open Source CDN for npm, GitHub, Javascript, and ESM
Bombardier3,948
2 months ago10October 15, 202022mitGo
Fast cross-platform HTTP benchmarking tool written in Go
Alternatives To Gearbox
Select To Compare


Alternative Project Comparisons
Readme


DeepSource

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

gearbox seeks to be

  • Secure 🔐
  • Fast 🚀
  • Easy to use 👓
  • Lightweight

Supported Go versions & installation

⚙️ 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 ⚙️

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

Who uses Gearbox

Gearbox ⚙️ 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

Popular Performance Projects
Popular Http Projects
Popular Software Performance Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Golang
Http
Rest
Router
Microservices
Performance