本文整理匯總了Golang中web.Get函數的典型用法代碼示例。如果您正苦於以下問題:Golang Get函數的具體用法?Golang Get怎麽用?Golang Get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Get函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterHandlers
// prefix should be something like "/" or "/wiki/"
func RegisterHandlers(prefix string) {
urlPrefix = prefix
web.Get(urlPrefix, func(ctx *web.Context) { redirect(ctx, "view", "FrontPage") })
web.Get(urlPrefix+"view/(.+)", viewHandler)
web.Get(urlPrefix+"edit/(.+)", editHandler)
web.Post(urlPrefix+"save/(.+)", saveHandler)
web.Get(urlPrefix+"cancel/(.+)", cancelHandler)
}
示例2: main
func main() {
viewInit()
mysqlInit()
web.Get("/edit/(.*)", edit)
web.Get("/(.*)", show)
web.Post("/(.*)", update)
web.Run("0.0.0.0:1111")
}
示例3: main
func main() {
m = monitor.NewMonitor(maxQuery, defaultTick)
web.Post("/dcb/submit", addSub)
web.Get("/dcb/", listSub)
web.Get("/dcb/list", listSub)
web.Get(`/dcb/remove/(.*)`, removeSub)
web.RunFcgi("127.0.0.1:9006")
//web.Run("127.0.0.1:9002")
}
示例4: main
func main() {
web.Get("/said", func() string { return tmpl })
web.Post("/say", func(ctx *web.Context) string {
input = ctx.Request.Form["said"][0]
return `<a href="/final">Click Here</a>`
})
web.Get("/final", func() string { return "You said " + input })
web.Run("0.0.0.0:9999")
}
示例5: RunWebServer
func RunWebServer(line *util.ChannelLine) {
util.WebOut = line
web.SetLogger(log.New(new(dummy), "", 0))
web.Config.CookieSecret = util.Settings.CookieSecret()
web.Get("/Liberator/(.*)", get)
web.Get("/(.*)", index)
web.Post("/Liberator/(.*)", post)
web.Run("0.0.0.0:" + strconv.Uitoa(util.Settings.WebPort()))
}
示例6: main
func main() {
/*setup redis connection*/
redisClient.Addr = "localhost:6379"
redisClient.Db = 13
/*setup web.go stuff*/
web.Get("/", index)
web.Get("/s/(.*)", show)
web.Get("/u/(.*)", redirect)
web.Post("/shorten", shorten)
web.Run("0.0.0.0:8080")
}
示例7: main
func main() {
starter.Start()
web.Config.StaticDir = "web-app/"
web.Post("/(.*)", starter.Get)
web.Get("/(.*)", starter.Get)
web.Run("0.0.0.0:8080")
}
示例8: main
func main() {
fmt.Printf("start\n")
out, err := ioutil.ReadFile("./index.php")
if err != nil {
return
}
s := string(out)
hello := func() string {
return s
}
web.Get("/", hello)
web.Get("/dnd/dnd.go", hello)
web.Post("/dnd/dnd.go", bye)
web.RunFcgi("127.0.0.1:9001")
//web.Run("0.0.0.0:9000")
}
示例9: main
func main() {
rand.Seed(time.Nanoseconds())
web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
web.Get("/said", func() string { return form })
web.Post("/say", func(ctx *web.Context) string {
uid := strconv.Itoa64(rand.Int63())
ctx.SetSecureCookie("user", uid, 3600)
users[uid] = ctx.Request.Params["said"]
return `<a href="/final">Click Here</a>`
})
web.Get("/final", func(ctx *web.Context) string {
uid, _ := ctx.GetSecureCookie("user")
return "You said " + users[uid]
})
web.Run("0.0.0.0:9999")
}
示例10: main
func main() {
f, err := os.Create("server.log")
if err != nil {
println(err.Error())
return
}
logger := log.New(f, "", log.Ldate|log.Ltime)
web.Get("/(.*)", hello)
web.SetLogger(logger)
web.Run("0.0.0.0:9999")
}
示例11: main
func main() {
flag.Parse()
Init(NewDiskvStore(*dir, uint32(*maxsz)), *pwhash)
log.Printf("nobodycares engine starting up...")
web.Get("/", get_root)
web.Get("/from/([0-9a-f]+)", get_from)
web.Get("/post", get_post)
web.Get("/edit/([0-9a-f]+)", get_edit)
web.Get("/([0-9a-f]+)/edit", get_edit)
web.Get("/delete/([0-9a-f]+)", get_delete)
web.Get("/([0-9a-f]+)/delete", get_delete)
web.Get("/([0-9a-f]+)", get_specific_id)
web.Get("/rss", get_rss)
web.Get("/css/(.*)", get_css)
web.Post("/post", post_post)
web.Post("/edit", post_edit)
web.Post("/delete", post_delete)
web.Run(fmt.Sprintf("%s:%d", *host, *port))
}
示例12: main
func main() {
// Main template
tpl = kasia.New()
err := tpl.Parse(tpl_txt)
if err != nil {
fmt.Println("Main template", err)
return
}
// This example can work in strict mode
tpl.Strict = true
// Web.go
web.Get("/(.*)", hello)
web.Run("0.0.0.0:9999")
}
示例13: main
func main() {
config := tls.Config{
Time: nil,
}
config.Certificates = make([]tls.Certificate, 1)
var err error
config.Certificates[0], err = tls.X509KeyPair([]byte(cert), []byte(pkey))
if err != nil {
println(err.Error())
return
}
// you must access the server with an HTTP address, i.e https://localhost:9999/world
web.Get("/(.*)", hello)
web.RunTLS("0.0.0.0:9999", &config)
}
示例14: main
func main() {
DBConnect()
defer DBDisconnect()
web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
web.Get("/", index)
web.Get("/month", month)
web.Get("/post", post)
web.Get("/rss.xml", rss)
web.Get("/index.php/feed/", rss)
web.Get("/index.php/feed/atom/", rss)
web.Get("/admin/edit", editGet)
web.Post("/admin/edit", editPost)
web.Get("/admin", adminGet)
web.Post("/admin", adminPost)
web.Run("0.0.0.0:9876")
}
示例15: main
func main() {
// Main template
tpl = kasia.New()
err := tpl.Parse(
"<html><body>Request #$cnt: $txt<br>\n$subtpl.Nested(subctx)</body></html>")
if err != nil {
fmt.Println("Main template", err)
return
}
// Nested template
data.subtpl = kasia.New()
err = data.subtpl.Parse("$for i+, v in vals: $i: $v<br>\n$end")
if err != nil {
fmt.Println("Nested template", err)
return
}
// Web.go
web.Get("/(.*)", hello)
web.Run("0.0.0.0:9999")
}