當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。