Ejemplo n.º 1
0
func main() {
	goweb.ConfigureDefaultFormatters()
	goweb.MapRest("/node", new(NodeController))
	goweb.MapRest("/user", new(UserController))
	fmt.Printf("Shock (port:%d, dataroot:%q, mongodb_host:%q, secretkey:%q)... starting\n", *conf.PORT, *conf.DATAROOT, *conf.MONGODB, *conf.SECRETKEY)
	goweb.ListenAndServe(":" + fmt.Sprintf("%d", *conf.PORT))
}
Ejemplo n.º 2
0
func main() {
	fmt.Printf("%s\n######### Conf #########\ndata-root:\t%s\nmongodb:\t%s\nsecretkey:\t%s\nsite-port:\t%d\napi-port:\t%d\n\n####### Starting #######\n",
		logo,
		conf.DATAPATH,
		conf.MONGODB,
		conf.SECRETKEY,
		conf.SITEPORT,
		conf.APIPORT,
	)

	c := make(chan int)
	goweb.ConfigureDefaultFormatters()
	// start site
	go func() {
		r := &goweb.RouteManager{}
		r.MapFunc("/raw", RawDir)
		r.MapFunc("/assets", AssetsDir)
		r.MapFunc("*", Site)
		c <- 1
		goweb.ListenAndServeRoutes(fmt.Sprintf(":%d", conf.SITEPORT), r)
		c <- 1
	}()
	<-c
	fmt.Printf("site :%d... running\n", conf.SITEPORT)

	// start api
	go func() {
		r := &goweb.RouteManager{}
		r.MapRest("/node", new(NodeController))
		r.MapRest("/user", new(UserController))
		r.MapFunc("*", ResourceDescription, goweb.GetMethod)
		c <- 1
		goweb.ListenAndServeRoutes(fmt.Sprintf(":%d", conf.APIPORT), r)
		c <- 1
	}()
	<-c
	fmt.Printf("api  :%d... running\n", conf.APIPORT)
	fmt.Printf("\n######### Log  #########\n")
	<-c
}