Exemplo n.º 1
0
func main() {
	flag.Parse()
	if *initdb {
		loadFirstRecord()
		return
	}
	var portString = fmt.Sprintf(":%d", *port)

	h := web.ProcessForm(10000, true, // limit size of form to 10k, enable xsrf
		web.NewRouter().
			Register("/debug/<:.*>", "*", web.NewRouter().
				Register("/debug/expvar", "GET", expvar.ServeWeb).
				Register("/debug/pprof/<:.*>", "*", pprof.ServeWeb)).
			Register("/static/<path:.*>", "GET", web.DirectoryHandler("static/", &web.ServeFileOptions{})).
			Register("/favicon.ico", "GET", web.FileHandler("static/favicon.ico", &web.ServeFileOptions{})).
			Register("/rss/<feed:(.*)>", "GET", rssHandler).
			Register("/", "GET", homeHandler).
			Register("/category/<category:(.*)>", "GET", categoryHandler).
			Register("/tags/<tag:(.*)>", "GET", tagsHandler).
			Register("/edit/<path:(.*)>", "GET", editHandler, "POST", saveHandler).
			Register("/search", "POST", searchHandler, "GET", searchHandler).
			Register("/<path:(.*)>", "GET", viewHandler))
	server.Run(portString, h)

}
Exemplo n.º 2
0
func main() {
	page = template.Must(template.New("index").Parse(body))

	server.Run(":8080",
		web.NewRouter().
			Register("/", "GET", index))
}
Exemplo n.º 3
0
func main() {
	db, db_err = mysql.DialTCP("localhost", "root", "asd123", "orders")
	if db_err != nil {
		log.Println(db_err)
		os.Exit(1)
	}

	port := ":8080"
	if envPort := os.Getenv("ORDERS_PORT"); envPort != "" {
		port = envPort
	}

	h := web.FormHandler(10000, false,
		web.NewRouter().
			Register("/", "GET", indexHandler).
			Register("/company/create", "GET", createCompanyFormHandler, "POST", createCompanyHandler).
			Register("/company/", "GET", viewCompanyHandler).
			Register("/order/create", "GET", createOrderFormHandler, "POST", createOrderHandler).
			Register("/order/", "GET", viewOrderHandler).
			Register("/event/create", "POST", createEventHandler).
			Register("/customer/create", "POST", createCustomerHandler).
			Register("/customer/", "GET", viewCustomerHandler).
			Register("/customer/paid/", "GET", paidHandler).
			Register("/line/create", "POST", createLineHandler).
			Register("/static/<path:.*>", "GET", web.DirectoryHandler("./static/", new(web.ServeFileOptions))))
	server.Run(port, h)
}
Exemplo n.º 4
0
func main() {
	const titleParam = "<title:[a-zA-Z0-9]+>"
	h := web.FormHandler(10000, true, // limit size of form to 10k, enable xsrf
		web.NewRouter().
			Register("/view/"+titleParam, "GET", viewHandler).
			Register("/edit/"+titleParam, "GET", editHandler, "POST", saveHandler))
	server.Run(":8080", h)
}
Exemplo n.º 5
0
func main() {
	flag.Parse()
	for i := 0; i < *count; i++ {
		go run()
	}
	h := web.HandlerFunc(expvar.ServeWeb)
	server.Run("127.0.0.1:8081", h)
}
Exemplo n.º 6
0
func main() {
	chatTempl = template.Must(template.New("chat").Parse(chatStr))
	go hub()
	server.Run(":8080",
		web.NewRouter().
			Register("/", "GET", chatFrameHandler).
			Register("/ws", "GET", chatWsHandler))
}
Exemplo n.º 7
0
func main() {
	flag.Parse()
	h := web.NewRouter().
		Register("/test", "GET", testHandler).
		Register("/gc", "GET", gcHandler).
		Register("/", "GET", expvar.ServeWeb)
	server.Run(":8080", h)
}
Exemplo n.º 8
0
func main() {
	flag.Parse()
	readSettings()
	h := web.FormHandler(10000, true, web.NewRouter().
		Register("/", "GET", home).
		Register("/login", "GET", login).
		Register("/callback", "GET", authCallback))

	server.Run(":8080", h)
}
Exemplo n.º 9
0
func main() {
	chatTempl = template.New(template.FormatterMap{"": template.HTMLFormatter})
	chatTempl.SetDelims("{{", "}}")
	if err := chatTempl.Parse(chatStr); err != nil {
		panic("template error: " + err.String())
	}
	go hub()
	server.Run(":8080",
		web.NewRouter().
			Register("/", "GET", chatFrameHandler).
			Register("/ws", "GET", chatWsHandler))
}
Exemplo n.º 10
0
func main() {
	/*
		log.Println(splitTags("Nick Carolyn Vanessa Hannah"))
		log.Println(splitTags("\"Hello World\""))
		log.Println(splitTags("\"@Carolyn Gerakines\" #dinner #date"))
		log.Println(splitTags("#meeting \"@Steve McGarrity\" #port #battle.net    \"\""))
		log.Println(splitTags("#api-wow +3h"))
	*/

	session, session_err = mgo.Mongo("localhost")
	if session_err != nil {
		panic(session_err)
	}
	defer session.Close()

	db, db_err = mysql.DialTCP("localhost", "root", "asd123", "gobook")
	if db_err != nil {
		log.Println(db_err)
		os.Exit(1)
	}

	port := ":8080"
	if envPort := os.Getenv("GOBOOK_PORT"); envPort != "" {
		port = envPort
	}

	h := web.FormHandler(10000, false,
		web.NewRouter().
			Register("/", "GET", displayIndex, "POST", createEntry).
			Register("/view/<entry:.*>", "GET", displayEntry).
			Register("/thread/<id:.*>", "GET", displayThread).
			Register("/calendar", "GET", displayCalendar).
			Register("/calendar/<year:.*>/<month:.*>/<day:.*>", "GET", displayDay).
			Register("/calendar/<year:.*>/<month:.*>", "GET", displayMonth).
			Register("/calendar/<year:.*>", "GET", displayYear).

			// Register("/migrate", "GET", migrate).
			Register("/archive", "GET", displayArchive).
			Register("/tag/<tag:.*>", "GET", displayTag).
			// Register("/entry/<id:.*>", "GET", displayEntry).
			Register("/api/tag/rename/", "POST", renameTag).
			Register("/summary/<year:.*>/<month:.*>", "GET", displayMonth).
			Register("/static/<path:.*>", "GET", web.DirectoryHandler("./static/", new(web.ServeFileOptions))))
	server.Run(port, h)
}
Exemplo n.º 11
0
func main() {
	/* log.Println(splitTags("Nick Carolyn Vanessa Hannah"))
	log.Println(splitTags("\"Hello World\""))
	log.Println(splitTags("\"@Carolyn Gerakines\" #dinner #date"))
	log.Println(splitTags("#meeting \"@Steve McGarrity\" #port #battle.net    \"\"")) */
	db, db_err = mysql.DialTCP("localhost", "root", "asd123", "gobook")
	if db_err != nil {
		log.Println(db_err)
		os.Exit(1)
	}

	port := ":8080"
	if envPort := os.Getenv("GOBOOK_PORT"); envPort != "" {
		port = envPort
	}

	h := web.FormHandler(10000, false,
		web.NewRouter().
			Register("/", "GET", displayIndex, "POST", createEntry).
			Register("/archive", "GET", displayArchive).
			Register("/static/<path:.*>", "GET", web.DirectoryHandler("./static/", new(web.ServeFileOptions))))
	server.Run(port, h)
}
Exemplo n.º 12
0
func main() {
	h := web.NewRouter().Register("/", "GET", serveHello)
	server.Run(":8080", h)
}
Exemplo n.º 13
0
func main() {
	router := web.NewRouter().
		Register("/<txt>/<num:[0-9]+>", "GET", ServeHTTP)
	server.Run(":8080", router)
}