本文整理匯總了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)
}
示例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)
}
示例3: Project
func Project() http.Handler {
mux := routes.New()
mux.Get("/project/:name([0-9a-z]+)", getProject)
return mux
}
示例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")
}
示例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)
}
}
示例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)
}
}
示例7: main
func main() {
initDB()
mux := routes.New()
mux.Get("/api/devices", getDevices)
http.Handle("/", mux)
http.ListenAndServe(":8088", nil)
}
示例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")
}
示例9: main
func main() {
mux := routes.New()
mux.Get("/api/:name", requestHandler)
http.Handle("/", mux)
http.ListenAndServe(":9091", nil)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}