Пример #1
0
func main() {
	app := weavebox.New()
	t := initTemplates()
	app.SetTemplateEngine(t)

	app.Get("/", renderIndex)
	app.Get("/user", renderUserDetail)
	app.Serve(3000)
}
Пример #2
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))
}