本文整理匯總了Golang中github.com/hoisie/web.Run函數的典型用法代碼示例。如果您正苦於以下問題:Golang Run函數的具體用法?Golang Run怎麽用?Golang Run使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Run函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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")
}
示例2: 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")
}
示例3: main
func main() {
flag.Parse()
web.Get("/", func() string {
return "Hello World"
})
web.Run(":8080")
}
示例4: 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))
}
示例5: main
func main() {
web.Get("/vnstat/(.*)/(.*)", vnstat)
web.Get("/dashboard/(.*)", dashboard)
web.Get("/list", ifacelist)
web.Get("/", home)
web.Run(port)
}
示例6: main
func main() {
pckg_dir = os.Getenv("GOPATH") + "/src/github.com/couchbaselabs/showfast/"
web.Config.StaticDir = pckg_dir + "app"
config_file, err := ioutil.ReadFile(pckg_dir + "config.json")
if err != nil {
log.Fatal(err)
}
var config Config
err = json.Unmarshal(config_file, &config)
if err != nil {
log.Fatal(err)
}
data_source = DataSource{config.CouchbaseAddress, config.BucketPassword}
web.Get("/", home)
web.Get("/admin", admin)
web.Get("/release", release)
web.Get("/feed", feed)
web.Get("/all_metrics", data_source.GetAllMetrics)
web.Get("/all_clusters", data_source.GetAllClusters)
web.Get("/all_timelines", data_source.GetAllTimelines)
web.Get("/all_benchmarks", data_source.GetAllBenchmarks)
web.Get("/all_runs", all_runs)
web.Get("/all_releases", data_source.GetAllReleases)
web.Get("/all_feed_records", data_source.GetAllFeedRecords)
web.Get("/get_comparison", get_comparison)
web.Post("/delete", delete)
web.Post("/reverse_obsolete", reverse_obsolete)
web.Run(config.ListenAddress)
}
示例7: main
func main() {
web.Get("/getuserinfo", getlist)
web.Get("/add/(.*)", addDrink)
web.Get("/del/(.*)", delDrink)
web.Run("127.0.0.1:9999")
}
示例8: 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)
}
示例9: main
func main() {
pckgDir = os.Getenv("GOPATH") + "/src/github.com/tahmmee/greenboard/"
web.Config.StaticDir = pckgDir + "app"
configFile, err := ioutil.ReadFile(pckgDir + "config.json")
if err != nil {
log.Fatal(err)
}
var config Config
err = json.Unmarshal(configFile, &config)
if err != nil {
log.Fatal(err)
}
// start web api
api = new(Api)
api.CouchbaseAddress = config.CouchbaseAddress
api.DataSources = make(map[string]*DataSource)
api.AddDataSource("server")
api.AddDataSource("mobile")
api.AddDataSource("sdk")
web.Get("/", api.GetIndex)
web.Get("/timeline", api.GetTimeline)
web.Get("/breakdown", api.GetBreakdown)
web.Get("/jobs", api.GetJobs)
web.Get("/versions", api.GetVersions)
web.Get("/categories", api.GetCategories)
web.Get("/jobs_missing", api.GetMissingJobs)
web.Run(config.ListenAddress)
}
示例10: main
func main() {
// Set the static directory for webgo
path := os.Getenv("GOPATH")
if path == "" {
fmt.Println("GOPATH NOT SET")
return
}
filepath := fmt.Sprintf("%s/../frontend/src/", path)
web.Config.StaticDir = filepath
// Setup logging
log := make(l4g.Logger)
// Create a default logger that is logging messages of FINE or higher
l4g.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter("error_log.log", false))
log.Close()
// Setup the DB
db.Init(path)
// Parse command line arguments
port := flag.Int("port", 80, "port number to start the server on")
flag.Parse()
url := fmt.Sprintf("0.0.0.0:%d", *port)
// Start the server!
serve.Routes()
web.Run(url)
}
示例11: 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)
}
示例12: 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())
}
示例13: 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")
}
示例14: main
func main() {
logger := log.New(ioutil.Discard, "", 0)
runtime.GOMAXPROCS(runtime.NumCPU())
web.Get("/(.*)", hello)
web.SetLogger(logger)
web.Run("0.0.0.0:8080")
}
示例15: 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)
}