traffic alternatives and similar packages
Based on the "Web Frameworks" category.
Alternatively, view traffic alternatives based on common mentions on social networks and blogs.
-
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin. -
go-kratos
Your ultimate Go microservices framework for the cloud-native era. -
Iris
The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket: -
Gorilla WebSocket
A fast, well-tested and widely used WebSocket implementation for Go. -
mux
A powerful HTTP router and URL matcher for building Go web servers with 🦍 -
chi
lightweight, idiomatic and composable router for building Go HTTP services -
GoFrame
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang. -
go-socket.io
socket.io library for golang, a realtime application framework. -
Macaron
Package macaron is a high productive and modular web framework in Go. -
Hertz
Go HTTP framework with high-performance and strong-extensibility for building micro-services. -
Faygo
Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct handler, faygo will automatically bind/verify the request parameters and generate the online API doc. -
render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses. -
pat
Sinatra style pattern muxer for Go’s net/http library, by the author of Sinatra. -
Atreugo
High performance and extensible micro web framework. Zero memory allocations in hot paths. -
tigertonic
A Go framework for building JSON web services inspired by Dropwizard -
fasthttprouter
A high performance fasthttp request router that scales well -
Goji
Goji is a minimalistic and flexible HTTP request multiplexer for Go (golang) -
Beego
beego is an open-source, high-performance web framework for the Go programming language. -
go-server-timing
Go (golang) library for creating and consuming HTTP Server-Timing headers -
Gearbox
Gearbox :gear: is a web framework written in Go with a focus on high performance -
golongpoll
golang long polling library. Makes web pub-sub easy via HTTP long-poll servers and clients :smiley: :coffee: :computer:
ONLYOFFICE Docs — document collaboration in your environment
Do you think we are missing an alternative of traffic or a related project?
Popular Comparisons
README
Traffic
Package traffic - a Sinatra inspired regexp/pattern mux for Go.
Installation
go get github.com/pilu/traffic
Features
- Regexp routing
- Before Filters
- Custom not found handler
- Middlewares
- Examples: Airbrake Middleware, Chrome Logger Middleware
- Templates/Views
- Easy Configuration
Development Features
- Shows errors and stacktrace in browser
- Serves static files
- Project Generator
development
is the default environment. The above middlewares are loaded only in development
.
If you want to run your application in production
, export TRAFFIC_ENV
with production
as value.
TRAFFIC_ENV=production your-executable-name
Installation
Dowload the Traffic
code:
go get github.com/pilu/traffic
Build the command line tool:
go get github.com/pilu/traffic/traffic
Create a new project:
traffic new hello
Run your project:
cd hello
go build && ./hello
You can use Fresh if you want to build and restart your application every time you create/modify/delete a file.
Example:
The following code is a simple example, the documentation in still in development.
For more examples check the examples
folder.
package main
import (
"net/http"
"github.com/pilu/traffic"
"fmt"
)
func rootHandler(w traffic.ResponseWriter, r *traffic.Request) {
fmt.Fprint(w, "Hello World\n")
}
func pageHandler(w traffic.ResponseWriter, r *traffic.Request) {
params := r.URL.Query()
fmt.Fprintf(w, "Category ID: %s\n", params.Get("category_id"))
fmt.Fprintf(w, "Page ID: %s\n", params.Get("id"))
}
func main() {
router := traffic.New()
// Routes
router.Get("/", rootHandler)
router.Get("/categories/:category_id/pages/:id", pageHandler)
router.Run()
}
Before Filters
You can also add "before filters" to all your routes or just to some of them:
router := traffic.New()
// Executed before all handlers
router.AddBeforeFilter(checkApiKey).
AddBeforeFilter(addAppNameHeader).
AddBeforeFilter(addTimeHeader)
// Routes
router.Get("/", rootHandler)
router.Get("/categories/:category_id/pages/:id", pageHandler)
// "/private" has one more before filter that checks for a second api key (private_api_key)
router.Get("/private", privatePageHandler).
AddBeforeFilter(checkPrivatePageApiKey)
Complete example:
func rootHandler(w traffic.ResponseWriter, r *traffic.Request) {
fmt.Fprint(w, "Hello World\n")
}
func privatePageHandler(w traffic.ResponseWriter, r *traffic.Request) {
fmt.Fprint(w, "Hello Private Page\n")
}
func pageHandler(w traffic.ResponseWriter, r *traffic.Request) {
params := r.URL.Query()
fmt.Fprintf(w, "Category ID: %s\n", params.Get("category_id"))
fmt.Fprintf(w, "Page ID: %s\n", params.Get("id"))
}
func checkApiKey(w traffic.ResponseWriter, r *traffic.Request) {
params := r.URL.Query()
if params.Get("api_key") != "foo" {
w.WriteHeader(http.StatusUnauthorized)
}
}
func checkPrivatePageApiKey(w traffic.ResponseWriter, r *traffic.Request) {
params := r.URL.Query()
if params.Get("private_api_key") != "bar" {
w.WriteHeader(http.StatusUnauthorized)
}
}
func addAppNameHeader(w traffic.ResponseWriter, r *traffic.Request) {
w.Header().Add("X-APP-NAME", "My App")
}
func addTimeHeader(w traffic.ResponseWriter, r *traffic.Request) {
t := fmt.Sprintf("%s", time.Now())
w.Header().Add("X-APP-TIME", t)
}
func main() {
router := traffic.New()
// Routes
router.Get("/", rootHandler)
router.Get("/categories/:category_id/pages/:id", pageHandler)
// "/private" has one more before filter that checks for a second api key (private_api_key)
router.Get("/private", privatePageHandler).
AddBeforeFilter(checkPrivatePageApiKey)
// Executed before all handlers
router.AddBeforeFilter(checkApiKey).
AddBeforeFilter(addAppNameHeader).
AddBeforeFilter(addTimeHeader)
router.Run()
}
Author
More
- Code: https://github.com/pilu/traffic/
- Mailing List: https://groups.google.com/d/forum/go-traffic
- Chat: https://gitter.im/pilu/traffic