当前位置: 首页>>代码示例>>Golang>>正文


Golang routes.New函数代码示例

本文整理汇总了Golang中github.com/drone/routes.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	nodeMap = make(map[uint64]string)
	FirstNode := "http://localhost:3000/"
	SecondNode := "http://localhost:3001/"
	ThirdNode := "http://localhost:3002/"

	keys = append(keys, murmur3.Sum64([]byte(FirstNode)))
	keys = append(keys, murmur3.Sum64([]byte(SecondNode)))
	keys = append(keys, murmur3.Sum64([]byte(ThirdNode)))

	keys.Sort()
	fmt.Println("Keys array is : ", keys)

	for _, element := range keys {
		switch element {

		case murmur3.Sum64([]byte(FirstNode)):
			nodeMap[element] = FirstNode
		case murmur3.Sum64([]byte(SecondNode)):
			nodeMap[element] = SecondNode
		case murmur3.Sum64([]byte(ThirdNode)):
			nodeMap[element] = ThirdNode
		}

	}

	mux := routes.New()
	mux.Put("/keys/:keyID/:value", PutValue)
	mux.Get("/keys/:keyID", RetrieveValue)

	http.Handle("/", mux)
	http.ListenAndServe(":8080", nil)

}
开发者ID:JasonGodinho,项目名称:Consistent-Hashing-of-key-value-pairs-using-Golang,代码行数:34,代码来源:client.go

示例2: init

func init() {

	mux := routes.New()
	mux.Get("/blog/", ViewArticleHandler)
	mux.Get("/blog/:year/:month/:day/:title", ViewArticleHandler)
	mux.Get("/blog/tag/:tag", TagHandler)
	mux.Get("/blog/archive/:year/:month", ArchiveHandler)

	//mux.Get("/blog/comment/post", SaveCommentHandler)
	mux.Post("/blog/comment", SaveCommentHandler)

	mux.Get("/admin", AdminHandler)
	mux.Get("/admin/article/post", SaveArticleHandler)
	mux.Get("/admin/article/edit", EditArticleHandler)
	mux.Get("/admin/article/update", UpdateArticleHandler)
	mux.Get("/admin/article/delete", DeleteArticleHandler)
	mux.Get("/admin/article/preview", PreViewArticleHandler)
	mux.Get("/admin/comment", ListCommentHandler)
	mux.Del("/admin/comment", DeleteCommentHandler)
	//mux.Get("/admin/comment/delete", DeleteCommentHandler)

	mux.Get("/feed/atom", RssHandler)
	mux.Get("/feed", RssHandler)
	mux.Get("/rss.xml", RssHandler)

	mux.Get("/sitemap.xml", SitemapHandler)
	mux.Get("/sitemap", SitemapHandler)
	mux.Get("/release", ReleaseHandler)
	mux.Get("/", IndexHandler)

	http.Handle("/", mux)
}
开发者ID:wendyeq,项目名称:iweb-gae,代码行数:32,代码来源:router.go

示例3: Project

func Project() http.Handler {
	mux := routes.New()

	mux.Get("/project/:name([0-9a-z]+)", getProject)

	return mux
}
开发者ID:6thmonth,项目名称:api.chunsik.org,代码行数:7,代码来源:project.go

示例4: main

func main() {
	sl, err := gurren.New([]string{"http://127.0.0.1:9200"}, "test", runtime.NumCPU())
	if err != nil {
		panic(err)
	}

	mux := routes.New()

	// Do handling here

	mux.Get("/", func(rw http.ResponseWriter, r *http.Request) {
		tpl, err := ace.Load("views/layout", "views/index", nil)
		if err != nil {
			http.Error(rw, err.Error(), http.StatusInternalServerError)
			return
		}

		if err := tpl.Execute(rw, nil); err != nil {
			http.Error(rw, err.Error(), http.StatusInternalServerError)
			return
		}
	})

	n := negroni.Classic()

	middleware.Inject(n)
	n.Use(sl)
	n.UseHandler(mux)

	n.Run(":3000")
}
开发者ID:Xe,项目名称:gurren,代码行数:31,代码来源:main.go

示例5: main

func main() {
	//http.HandleFunc("/", common.Index) //设置访问的路由
	//http.HandleFunc("/login", common.Login) //设置访问的路由
	//http.HandleFunc("/upload", common.Upload) //设置访问的路由
	//http.HandleFunc("/reg", user.Reg) //设置访问的路由
	//http.HandleFunc("/test", common.test) //设置访问的路由

	http.Handle("/upload/", http.StripPrefix("/upload/", http.FileServer(http.Dir("upload"))))
	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))
	mux := routes.New()
	mux.Get("/user/:uid", user.Show)
	mux.Get("/", common.Index) //设置访问的路由

	mux.Get("/login", common.Login)  //设置访问的路由
	mux.Post("/login", common.Login) //设置访问的路由

	mux.Get("/upload", common.Upload)  //设置访问的路由
	mux.Post("/upload", common.Upload) //设置访问的路由

	mux.Get("/reg", user.Reg)  //设置访问的路由
	mux.Post("/reg", user.Reg) //设置访问的路由

	http.Handle("/", mux)
	err := http.ListenAndServe(":8080", nil) //设置监听的端口

	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
开发者ID:vluo,项目名称:golang_practise,代码行数:29,代码来源:index.go

示例6: main

func main() {
	port := fmt.Sprintf(":%d", pubConfig.Port)
	mux := routes.New()
	mux.Get("/", GetHelp)
	mux.Get("/repo", ListRepos)
	mux.Get("/repo/:ID", GetRepo)
	//either refresh or add
	mux.Post("/repo", AddRepo)
	//either refresh or modify (especially enable/disable)
	mux.Post("/repo/:ID", ModifyRepo)

	mux.Get("/case", ListCases)
	//TODO: add group/name in the future
	mux.Get("/case/:ID", GetCase)
	mux.Get("/case/:ID/report", GetCaseReport)

	//The task api is not necessary now, just used for web in the future.
	//Add a new task by the case id
	mux.Get("/task", ListTasks)
	//Add task : turn a case into a task, but donnot send to scheduler
	mux.Post("/task", AddTask)
	mux.Get("/task/:TaskID", GetTaskStatus)
	mux.Get("/task/:TaskID/report", GetTaskReport)
	// apply/deploy/run/collect/destroy
	mux.Post("/task/:TaskID", PostTaskAction)

	http.Handle("/", mux)
	logrus.Infof("Listen to port ", port)
	err := http.ListenAndServe(port, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
开发者ID:pombredanne,项目名称:oct-engine,代码行数:33,代码来源:main.go

示例7: main

func main() {
	initDB()
	mux := routes.New()
	mux.Get("/api/devices", getDevices)
	http.Handle("/", mux)
	http.ListenAndServe(":8088", nil)
}
开发者ID:ajaymenon,项目名称:smarthome,代码行数:7,代码来源:server_main.go

示例8: main

// main is the entry point for lagann
func main() {
	flag.Parse()

	client = etcd.NewClient([]string{"http://" + *etcdmachine + ":4001"})

	routing := http.NewServeMux()
	usermux := routes.New()

	n := negroni.Classic()
	n.UseHandler(routing)

	routing.HandleFunc(constants.ROOT_MUXPATH, root)
	routing.HandleFunc(constants.REGISTER_URL, register)
	routing.HandleFunc(constants.LOGIN_URL, login)

	usermux.Post(constants.APP_CREATE_URL, createApp)
	usermux.Post(constants.APP_SHARING_URL, addSharing)

	auth, _ := auth.NewAuth("http://"+*etcdmachine+":4001", constants.ETCD_LAGANN_AUTHKEYS)

	routing.Handle(constants.USER_MUXPATH, negroni.New(
		auth,
		negroni.Wrap(usermux),
	))

	n.Run(":3000")
}
开发者ID:mehulsbhatt,项目名称:flitter,代码行数:28,代码来源:main.go

示例9: main

func main() {

	mux := routes.New()
	mux.Get("/api/:name", requestHandler)
	http.Handle("/", mux)
	http.ListenAndServe(":9091", nil)

}
开发者ID:DexterB,项目名称:Go,代码行数:8,代码来源:webhello.go

示例10: main

func main() {
	mux := routes.New()
	mux.Get("/:last/:first", Whoami)
	pwd, _ := os.Getwd()
	mux.Static("/static", pwd)
	http.Handle("/", mux)
	http.ListenAndServe(":8088", nil)
}
开发者ID:axlrose,项目名称:golang_samples,代码行数:8,代码来源:testroutes.go

示例11: init

func init() {
	mux := routes.New()

	mux.Get("/users", func(res http.ResponseWriter, req *http.Request) {
		fmt.Fprintf(res, "GET: /users")
	})

	http.Handle("/users", mux)
}
开发者ID:alexeyco,项目名称:go-practics,代码行数:9,代码来源:users.go

示例12: main

func main() {
	mux := routes.New()
	mux.Get("/user/:uid", getuser)
	mux.Post("/user/", adduser)
	mux.Del("/user/:uid", deleteuser)
	mux.Put("/user/:uid", modifyuser)
	http.Handle("/", mux)
	http.ListenAndServe(":8088", nil)
}
开发者ID:jeffreymu,项目名称:golang_demo_1,代码行数:9,代码来源:go_rest_1.go

示例13: main

func main() {
	mux := routes.New()
	mux.Post("/locations/", addLocation)
	mux.Get("/locations/:locationId", findLocation)
	mux.Put("/locations/:locationId", updateLocation)
	mux.Del("/locations/:locationId", deleteLocation)
	http.Handle("/", mux)
	http.ListenAndServe(":8088", nil)
}
开发者ID:savioferns321,项目名称:Google_Trip_Planner,代码行数:9,代码来源:server.go

示例14: main

func main() {
	mux := routes.New()
	mux.Get("/", handler)
	mux.Get("/rentals/:id", getRentalHandler)
	//http.HandleFunc("/view/", viewHandler)
	//http.HandleFunc("/", handler)
	http.Handle("/", mux)
	http.ListenAndServe(":3000", nil)
}
开发者ID:Ligerlilly,项目名称:1stGoServer,代码行数:9,代码来源:app.go

示例15: main

func main() {

	mux := routes.New()
	mux.Get("/:user/:topic", getSlide)
	mux.Post("/:user/:topic", postSlide)
	mux.Put("/:user/:topic", putSlide)
	http.Handle("/", mux)
	http.ListenAndServe(":7777", nil)
}
开发者ID:secreek,项目名称:fowllow,代码行数:9,代码来源:server.go


注:本文中的github.com/drone/routes.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。