Esempio n. 1
0
func main() {
	app := weavebox.New()
	t := initTemplates()
	app.SetTemplateEngine(t)

	app.Get("/", renderIndex)
	app.Get("/user", renderUserDetail)
	app.Serve(3000)
}
Esempio n. 2
0
func main() {
	var listen = flag.Int("listen", 3000, "target listen address of the application")
	flag.Parse()

	app := weavebox.New()
	app.EnableAccessLog = true
	app.Get("/", helloHandler)
	log.Fatal(app.Serve(*listen))
}
Esempio n. 3
0
func main() {
	listen := flag.Int("listen", 3000, "listen address of the application")
	flag.Parse()

	app := weavebox.New()

	// centralizing our errors returned from middleware and request handlers
	app.SetErrorHandler(errorHandler)

	app.Get("/hello/:name", greetingHandler)
	app.Use(dbContextHandler)

	// make a subrouter and register some middleware for it
	admin := app.Box("/admin")
	admin.Get("/:name", adminGreetingHandler)
	admin.Use(authenticate)

	log.Fatal(app.Serve(*listen))
}