func NotFound(w http.ResponseWriter, r *http.Request) {
	http.Error(w, "Umm... have you tried turning it off and on again?", 404)
}
NotFound is a 404 handler.
package main
import (
	"fmt"
	"io"
	"net/http"
	"regexp"
	"strconv"
	"time"
	"github.com/goji/param"
	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web"
	"github.com/zenazn/goji/web/middleware"
)
func main() {
	goji.Get("/", Root)
	goji.Get("/greets", http.RedirectHandler("/", 301))
	goji.Post("/greets", NewGreet)
	goji.Get("/users/:name", GetUser)
	goji.Get(regexp.MustCompile(`^/greets/(?P<id>\d+)$`), GetGreet)
	goji.Use(PlainText)
	admin := web.New()
	goji.Handle("/admin/*", admin)
	admin.Use(middleware.SubRouter)
	admin.Use(SuperSecure)
	admin.Get("/", AdminRoot)
	admin.Get("/finances", AdminFinances)
	goji.Get("/admin", http.RedirectHandler("/admin/", 301))
	goji.NotFound(NotFound)
	goji.Get("/waitforit", WaitForIt)
	goji.Serve()
}
func Root(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Gritter\n======\n\n")
	for i := len(Greets) - 1; i >= 0; i-- {
		Greets[i].Write(w)
	}
}
func NewGreet(w http.ResponseWriter, r *http.Request) {
	var greet Greet
	r.ParseForm()
	err := param.Parse(r.Form, &greet)
	if err != nil || len(greet.Message) > 140 {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	Greets = append(Greets, greet)
	url := fmt.Sprintf("/greets/%d", len(Greets)-1)
	http.Redirect(w, r, url, http.StatusCreated)
}
func GetUser(c web.C, w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Gritter\n======\n\n")
	handle := c.URLParams["name"]
	user, ok := Users[handle]
	if !ok {
		http.Error(w, http.StatusText(404), 404)
		return
	}
	user.Write(w, handle)
	io.WriteString(w, "\nGreets:\n")
	for i := len(Greets) - 1; i >= 0; i-- {
		if Greets[i].User == handle {
			Greets[i].Write(w)
		}
	}
}
func GetGreet(c web.C, w http.ResponseWriter, r *http.Request) {
	id, err := strconv.Atoi(c.URLParams["id"])
	if err != nil {
		http.Error(w, http.StatusText(404), 404)
		return
	}
	greet := Greets[id]
	io.WriteString(w, "Gritter\n======\n\n")
	greet.Write(w)
}
func WaitForIt(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "This is going to be legend... (wait for it)\n")
	if fl, ok := w.(http.Flusher); ok {
		fl.Flush()
	}
	time.Sleep(15 * time.Second)
	io.WriteString(w, "...dary! Legendary!\n")
}
func AdminRoot(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Gritter\n======\n\nSuper secret admin page!\n")
}
func AdminFinances(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Gritter\n======\n\nWe're broke! :(\n")
}