• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang web.Run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/hoisie/web.Run函数的典型用法代码示例。如果您正苦于以下问题:Golang Run函数的具体用法?Golang Run怎么用?Golang Run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
}
开发者ID:elbing,项目名称:jailblog,代码行数:25,代码来源:jailBlogController.go


示例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")
}
开发者ID:xyproto,项目名称:archlinuxno,代码行数:28,代码来源:archlinuxno.go


示例3: main

func main() {
	flag.Parse()
	web.Get("/", func() string {
		return "Hello World"
	})
	web.Run(":8080")
}
开发者ID:john-griffin,项目名称:goreman,代码行数:7,代码来源:web.go


示例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))

}
开发者ID:jahrain,项目名称:gmb,代码行数:31,代码来源:mbroker.go


示例5: main

func main() {
	web.Get("/vnstat/(.*)/(.*)", vnstat)
	web.Get("/dashboard/(.*)", dashboard)
	web.Get("/list", ifacelist)
	web.Get("/", home)
	web.Run(port)
}
开发者ID:orvice,项目名称:iVnstat,代码行数:7,代码来源:server.go


示例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)
}
开发者ID:vmx,项目名称:showfast,代码行数:35,代码来源:main.go


示例7: main

func main() {
	web.Get("/getuserinfo", getlist)
	web.Get("/add/(.*)", addDrink)
	web.Get("/del/(.*)", delDrink)
	web.Run("127.0.0.1:9999")

}
开发者ID:remydb,项目名称:go_fiddles,代码行数:7,代码来源:drinks_tracker.go


示例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)
}
开发者ID:nakamuray,项目名称:fileproxy,代码行数:29,代码来源:fileproxy.go


示例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)
}
开发者ID:subalakr,项目名称:greenboard,代码行数:32,代码来源:main.go


示例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)
}
开发者ID:CDargis,项目名称:SecurityAdventures,代码行数:29,代码来源:main.go


示例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)

}
开发者ID:GeorgeErickson,项目名称:6.824-Final-Project,代码行数:25,代码来源:main.go


示例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())
}
开发者ID:jseaidou,项目名称:monet,代码行数:34,代码来源:monet.go


示例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")
}
开发者ID:abrookins,项目名称:go_iching_api,代码行数:7,代码来源:iching_api.go


示例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")
}
开发者ID:nareshv,项目名称:FrameworkBenchmarks,代码行数:7,代码来源:hello.go


示例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)
}
开发者ID:zheng-ji,项目名称:goHttpDns,代码行数:9,代码来源:initial.go


示例16: main

func main() {
	f, _ := os.Create("server.log")
	logger := log.New(f, "", log.Ldate|log.Ltime)
	runtime.GOMAXPROCS(runtime.NumCPU())
	web.Get("/(.*)", hello)
	web.SetLogger(logger)
	web.Run("0.0.0.0:8080")
}
开发者ID:thangnvaltplus,项目名称:FrameworkBenchmarks,代码行数:8,代码来源:hello.go


示例17: startServer

func startServer(port string) {
	models.SetDatabase(&globalConfiguration.Database)

	web.Get("/?", index)
	generateRoutes()

	web.Run("0.0.0.0:" + port)
}
开发者ID:xyproto,项目名称:forum,代码行数:8,代码来源:server.go


示例18: 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")
}
开发者ID:Chownie,项目名称:SteamMatcher,代码行数:8,代码来源:main.go


示例19: main

func main() {
	rand.Seed(time.Now().UnixNano())
	port := os.Getenv("PORT")
	if port == "" {
		port = "9999"
	}
	web.Get("/(.*)", hello)
	web.Run(":" + port)
}
开发者ID:askedrelic,项目名称:go-heroku-example,代码行数:9,代码来源:web.go


示例20: main

func main() {

	// parse command line arguments
	flag.Parse()
	web.Get("/(list)", list)
	//web.Get("/(.*)", list)
	//    web.SetLogger(glog)
	web.Run("0.0.0.0:9999")
}
开发者ID:redhotpenguin,项目名称:jaws,代码行数:9,代码来源:jaws.go



注:本文中的github.com/hoisie/web.Run函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang web.Context类代码示例发布时间:2022-05-28
下一篇:
Golang web.Post函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap