本文整理匯總了Golang中github.com/hoisie/web.Get函數的典型用法代碼示例。如果您正苦於以下問題:Golang Get函數的具體用法?Golang Get怎麽用?Golang Get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Get函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
fmt.Printf("Starting server ... ")
web.Get("/iching/hexagrams/(.*)", hexagram)
web.Get("/iching/hexagrams", allHexagrams)
web.Get("/iching/reading", reading)
web.Run("0.0.0.0:9999")
}
示例2: main
func main() {
go mainHub.Run()
document_hubs = setupDocuments()
chat_hubs = setupChats()
// Get hostname if specified
args := os.Args
host := "0.0.0.0:8080"
if len(args) == 2 {
host = args[1]
}
parts := strings.Split(host, ":")
fmt.Println(parts)
web.Config.Addr = parts[0]
web.Config.Port, _ = strconv.Atoi(parts[1])
web.Config.StaticDir = filepath.Join(os.Getenv("GOPATH"), "src/server/client/public")
web.Get("/", home)
web.Get("/ws", serveWs)
web.Get("/rest/documents", getDocuments)
web.Put("/rest/documents/(.*)", setDocumentTitle)
web.Delete("/rest/documents/(.*)", deleteDocument)
web.Get("/documents/(.*)", documentStream)
web.Get("/chat/(.*)", chatStream)
web.Run(host)
}
示例3: main
func main() {
web.Get("/", indexPage)
web.Post("/upload/(.*)", uploader)
web.Get("/download/(.*)", downloader)
bindHost := flag.String("bind", "0.0.0.0:8000", "bind to this address:port")
realHost := flag.String("real-host", "", "real hostname client use to connect")
realScheme := flag.String("real-scheme", "", "real scheme client use to connect")
useXForwardedFor := flag.Bool("use-x-forwarded-for", false, "use X-Forwarded-For header for logging")
logfile := flag.String("logfile", "", "log file (defaulg: stderr)")
flag.Parse()
appConfig = AppConfig{
*realScheme,
*realHost,
"http",
*bindHost,
*useXForwardedFor,
}
if *logfile != "" {
web.SetLogger(NewRotateLog(*logfile, 1024*1024, 10, "", log.Ldate|log.Ltime))
}
web.Run(appConfig.BindHost)
}
示例4: Attach
// Attach the blog app frontend
func Attach(url string) {
web.Get(url+"blog/page/(\\d+)", blogPage)
web.Get(url+"blog/([^/]+)/", blogDetail)
web.Get(url+"blog/", blogIndex)
web.Get(url+"stream/page/(\\d+)", streamPage)
web.Get(url+"stream/", streamIndex)
}
示例5: main
// TODO: One database per site
func main() {
// UserState with a Redis Connection Pool
userState := permissions.NewUserState(0, true, ":6379")
defer userState.Close()
// The archlinux.no webpage,
mainMenuEntries := ServeArchlinuxNo(userState, "/js/jquery-"+JQUERY_VERSION+".min.js")
ServeEngines(userState, mainMenuEntries)
// Compilation errors, vim-compatible filename
web.Get("/error", webhandle.GenerateErrorHandle("errors.err"))
web.Get("/errors", webhandle.GenerateErrorHandle("errors.err"))
// Various .php and .asp urls that showed up in the log
genericsite.ServeForFun()
// TODO: Incorporate this check into web.go, to only return
// stuff in the header when the HEAD method is requested:
// if ctx.Request.Method == "HEAD" { return }
// See also: curl -I
// Serve on port 3009 for the Nginx instance to use
web.Run("0.0.0.0:3009")
}
示例6: main
func main() {
web.Get("/vnstat/(.*)/(.*)", vnstat)
web.Get("/dashboard/(.*)", dashboard)
web.Get("/list", ifacelist)
web.Get("/", home)
web.Run(port)
}
示例7: main
func main() {
bind_addr := flag.String("bind_ip", "127.0.0.1", "bind ip address")
http_port := flag.Int("http_port", 9999, "listen http port")
rpc_port := flag.Int("rpc_port", 9998, "listen rpc port")
flag.Parse()
go func() {
addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", *bind_addr, *rpc_port))
listener, _ := net.ListenTCP("tcp", addr)
rpcservice := new(RPCService)
rpc.Register(rpcservice)
rpc.HandleHTTP()
for {
conn, _ := listener.Accept()
go rpc.ServeCodec(jsonrpc.NewServerCodec(conn))
}
}()
web.Get("/api/topics/([a-zA-Z0-9_\\-]+)/subscribers/([a-zA-Z0-9_\\-]+)/messages", APIGetTopicMessages)
web.Post("/api/topics/([a-zA-Z0-9_\\-]+)/subscribers/([a-zA-Z0-9_\\-]+)/messages", APIPostTopicMessage)
web.Get("/api/topics/([a-zA-Z0-9_\\-]+)", APIGetTopic)
web.Post("/api/topics/([a-zA-Z0-9_\\-]+)", APIUpdateTopic)
//web.Get("/api/topics", APIGetTopics)
web.Get("/api/subscribers/([a-zA-Z0-9_\\-]+)", APIGetSubscriber)
web.Post("/api/subscribers/([a-zA-Z0-9_\\-]+)", APIUpdateSubscriber)
//web.Get("/api/topics/(.+)/subscribers/(.+)", APIGetTopicSubscriber)
//web.Get("/api/topics/(.+)/subscribers", APIGetTopicSubscribers)
web.Run(fmt.Sprintf("%s:%d", *bind_addr, *http_port))
}
示例8: main
func main() {
web.Get("/getuserinfo", getlist)
web.Get("/add/(.*)", addDrink)
web.Get("/del/(.*)", delDrink)
web.Run("127.0.0.1:9999")
}
示例9: main
func main() {
fmt.Printf("Using config %s\n", conf.Path)
fmt.Printf("Using models:\n")
for _, m := range db.Models {
t := reflect.TypeOf(m)
fmt.Printf(" %s\n", fmt.Sprintf("%s", t)[1:])
}
template.Init(conf.Config.TemplatePaths)
fmt.Printf(conf.Config.String())
web.Config.StaticDir = conf.Config.StaticPath
db.Connect(conf.Config.DbHostString(), conf.Config.DbName)
db.RegisterAllIndexes()
blog.AttachAdmin("/admin/")
blog.Attach("/")
app.AttachAdmin("/admin/")
app.Attach("/")
gallery.AttachAdmin("/admin/")
gallery.Attach("/")
web.Get("/$", blog.Index)
web.Get("/(.*)", blog.Flatpage)
app.AddPanel(&blog.PostPanel{})
app.AddPanel(&blog.UnpublishedPanel{})
app.AddPanel(&blog.PagesPanel{})
app.AddPanel(&gallery.GalleryPanel{})
web.Run(conf.Config.HostString())
}
示例10: main
func main() {
viewInit()
web.Config.CookieSecret = "UXVpZXJvIGEgbWkgcGVxdWXxbyBoaWpvIE1hcmNvcw=="
// Init API library
jailgo.EntryInit()
jailgo.ArtInit()
jailgo.LoginInit()
// Principal, comment and search pages
web.Get("/", showblog)
web.Get("/comment(.*)", entry)
web.Get("/search", search)
// Editing articles and comments
web.Post("/updateArt", updateArt)
web.Post("/updateEntry", updateEntry)
// Login and Administration
web.Post("/login", login)
web.Get("/admin", admin)
// Web server
web.Run("0.0.0.0:9085")
}
示例11: main
func main() {
web.Get("/()", IndexLoad)
web.Get("/match/()", CompareNames)
//web.Get("/test/(.*)", TestLoadHome)
web.Get("/static/(.*)", Sendstatic)
//STARTING PROCEDURE
web.Run("0.0.0.0:8830")
}
示例12: Loop
// Loop Func Register web interface
func Loop() {
// 注冊web接口
web.Get("/ping", PingHandler)
web.Get("/d", ResolveHandler)
addr := fmt.Sprintf("%s:%s", appConfig.Listen, appConfig.Port)
web.Run(addr)
}
示例13: ServeSearchPages
func ServeSearchPages(basecp BaseCP, state *permissions.UserState, cps PageCollection, cs *ColorScheme, tpg TemplateValueGenerator) {
searchCP := basecp(state)
searchCP.ContentTitle = "Search results"
searchCP.ExtraCSSurls = append(searchCP.ExtraCSSurls, "/css/search.css")
// Note, no slash between "search" and "(.*)". A typical search is "/search?q=blabla"
web.Get("/search(.*)", searchCP.WrapWebHandle(GenerateSearchHandle(cps), tpg))
web.Get("/css/search.css", GenerateSearchCSS(cs))
}
示例14: ServePages
// Site is ie. "archlinux.no" and used for sending confirmation emails
func (ue *UserEngine) ServePages(site string) {
state := ue.state
web.Post("/register/(.*)", GenerateRegisterUser(state, site))
web.Post("/register", GenerateNoJavascriptMessage())
web.Post("/login/(.*)", GenerateLoginUser(state))
web.Post("/login", GenerateNoJavascriptMessage())
web.Get("/logout", GenerateLogoutCurrentUser(state))
web.Get("/confirm/(.*)", GenerateConfirmUser(state))
}
示例15: main
func main() {
parse_flags()
var config ViaConfig
var configFile string
args := flag.Args()
if len(args) < 1 {
configFile = "production.json"
} else {
configFile = args[0]
}
log.Print("loading config from " + configFile + "... ")
config, err := LoadConfig(configFile)
if err != nil {
log.Printf("failed: %s\n", configFile, err.Error())
return
}
// Handle SIGINT and SIGKILL
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGABRT)
go func() {
for sig := range c {
log.Printf("received %v, exiting...", sig)
os.Exit(1)
}
}()
procs := runtime.NumCPU()
runtime.GOMAXPROCS(procs)
log.Printf("starting server, running on %d cores...", procs)
via := NewVia(Debug, expiry, config.DataDir)
server := Server{Via: via, Host: config.Host, Port: config.Port, AllowedCountries: config.AllowedCountries}
// Basic
web.Get("/", Splash)
web.Get("/status", server.GetServerStatus)
// Dmatrix
web.Post("/matrix/", server.PostMatrix)
// Path
web.Post("/paths", server.PostPaths)
web.Match("OPTIONS", "/(.*)", Options)
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
web.Run(fmt.Sprintf("%s:%d", config.Host, config.Port))
}