示例#1
0
文件: web.go 项目: robxu9/reservoir
func main() {
	goweb.MapFunc("/test/{func}/respond", func(c *goweb.Context) {
		fmt.Fprintf(c.ResponseWriter, "You called me with %s!", c.PathParams["func"])
	})

	goweb.ListenAndServe(":8080")
}
示例#2
0
文件: toris.go 项目: beer-root/toris
func main() {

	if toris.ShowModules {
		log.Println("Installed modules", toris.Context.ModuleList())
		os.Exit(0)
	}

	c := toris.Context.ConfigFile

	serverPort, _ := c.GetInt("server", "port")

	// Add default result formatter (JSON)
	goweb.ConfigureDefaultFormatters()

	// start the modules
	for name, _ := range toris.Context.ModuleList() {
		log.Println("Starting module " + name)
		err := toris.Context.Start(name)
		if err != nil {
			log.Println("[ERROR]", "An exception was raised", err)
		} else {
			log.Println("OK")
		}
	}

	serverUrl := fmt.Sprintf(":%d", serverPort)
	log.Println("Starting server on: " + serverUrl)
	log.Fatal(goweb.ListenAndServe(serverUrl))

}
示例#3
0
文件: main.go 项目: rails0330/goweb
func main() {

	handler := func(c *goweb.Context) {
		name := c.PathParams["name"]
		animal := c.PathParams["animal"]
		fmt.Fprintf(c.ResponseWriter, "Hey %s, your favorite animal is a %s", name, animal)
	}

	goweb.MapFunc("/people/{name}/animals/{animal}", handler)
	goweb.ListenAndServe(":8080")
}
示例#4
0
文件: main.go 项目: rails0330/goweb
func main() {
	controller := new(MyController)
	goweb.MapRest("/api", controller)
	goweb.ListenAndServe(":8080")
}