Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gogearbox/gearbox
Gearbox :gear: is a web framework written in Go with a focus on high performance
https://github.com/gogearbox/gearbox
api fasthttp framework gearbox go golang http microservice middleware performance rest router web
Last synced: 10 days ago
JSON representation
Gearbox :gear: is a web framework written in Go with a focus on high performance
- Host: GitHub
- URL: https://github.com/gogearbox/gearbox
- Owner: gogearbox
- License: mit
- Created: 2020-04-25T01:28:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-29T07:26:20.000Z (about 1 year ago)
- Last Synced: 2024-05-29T21:30:00.359Z (5 months ago)
- Topics: api, fasthttp, framework, gearbox, go, golang, http, microservice, middleware, performance, rest, router, web
- Language: Go
- Homepage: https://gogearbox.com
- Size: 432 KB
- Stars: 746
- Watchers: 20
- Forks: 54
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-egypt-opensource - gogearbox/gearbox - gearbox is a web framework written in Go with a focus on high performance and memory optimization (Projects / Web Frameworks)
- awesome-go-extra - gearbox - 04-25T01:28:37Z|2022-08-16T07:01:45Z| (Web Frameworks / Fail injection)
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](https://github.com/valyala/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](https://golang.org/dl/))
Just use [go get](https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) to download and install gearbox
```bash
go get -u github.com/gogearbox/gearbox
```### Examples
```go
package mainimport (
"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
```go
package mainimport (
"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
```go
package mainimport (
"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
```go
package mainimport (
"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](https://gogearbox.com/docs/benchmarks)
### Contribute & Support
+ Add a [GitHub Star](https://github.com/gogearbox/gearbox/stargazers)
+ [Suggest new features, ideas and optimizations](https://github.com/gogearbox/gearbox/issues)
+ [Report issues](https://github.com/gogearbox/gearbox/issues)
+ Donating a [cup of coffee](https://buymeacoff.ee/gearbox)Check [Our Docs](https://gogearbox.com/docs) for more information about **gearbox** and how to **contribute**
### Sponsors
Organizations that are helping to manage, promote, and support **Gearbox** :gear:| [](https://www.trella.app) |
|:-: |
| [trella](https://www.trella.app): *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[](https://erply.com)
[](https://www.trella.app)### Contributors
### Get in touch!
Feel free to chat with us on [Discord](https://discord.com/invite/CT8my4R), or email us at [[email protected]]([email protected]) if you have questions, or suggestions
### License
gearbox is licensed under [MIT License](LICENSE)
Logo is created by [Mahmoud Sayed](https://www.facebook.com/mahmoudsayedae) and distributed under [Creative Commons License](https://creativecommons.org/licenses/by-sa/4.0/)
#### Third-party library licenses
- [FastHTTP](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [json-iterator](https://github.com/json-iterator/go/blob/master/LICENSE)