Goji is a HTTP request multiplexer, similar to net/http.ServeMux.
It compares incoming requests to a list of registered Patterns, and
dispatches to the http.Handler that corresponds to the first
matching Pattern. Goji also supports Middleware (composable
shared functionality applied to every request) and uses the standard
context package to store request-scoped values.
package main
import (
"fmt"
"net/http"
"github.com/kenshaw/goji"
)
func hello(w http.ResponseWriter, r *http.Request) {
name := pat.Param(r, "name")
fmt.Fprintf(w, "Hello, %s!", name)
}
func main() {
mux := goji.NewMux()
mux.HandleFunc(pat.Get("/hello/:name"), hello)
http.ListenAndServe("localhost:8000", mux)
}Please refer to Goji's GoDoc Documentation for a full API reference.