示例#1
0
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")
}
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
0
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
0
文件: app.go 项目: elimisteve/monet
// 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
0
// 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
0
文件: server.go 项目: orvice/iVnstat
func main() {
	web.Get("/vnstat/(.*)/(.*)", vnstat)
	web.Get("/dashboard/(.*)", dashboard)
	web.Get("/list", ifacelist)
	web.Get("/", home)
	web.Run(port)
}
示例#7
0
文件: mbroker.go 项目: jahrain/gmb
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
0
func main() {
	web.Get("/getuserinfo", getlist)
	web.Get("/add/(.*)", addDrink)
	web.Get("/del/(.*)", delDrink)
	web.Run("127.0.0.1:9999")

}
示例#9
0
文件: monet.go 项目: jseaidou/monet
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
0
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
0
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
0
// 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
0
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
0
// 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
0
文件: server.go 项目: nfleet/via
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))
}
示例#16
0
func Routes() {

	// "Brain" stuff
	web.Get("/scoreboard", getScoreboard)
	web.Get("/publicUsers", getPublicUsers)
	web.Put("/validateFlag", domainHandler(validateFlag))

	// To be implemented ?
	web.Post("/newuser", domainHandler(newUser))
}
示例#17
0
文件: site.go 项目: rredpoppy/gosite
func main() {
	config, err := getConfig()
	if err != nil {
		panic(err.Error())
	}
	web.Get("/([a-zA-Z0-9-]*)", handleSection)
	web.Get("/([a-zA-Z0-9-]+)/([0-9]+)", handlePaginatedSection)
	web.Get("/([a-zA-Z0-9-]+)/([a-zA-Z]{1}[a-zA-Z0-9-]*)", handlePage)
	web.Run(config.ServerIp)
}
示例#18
0
func ServeForFun() {
	// These appeared in the log
	bogus := []string{"/signup", "/wp-login.php", "/join.php", "/register.php", "/profile.php", "/user/register/", "/tools/quicklogin.one", "/sign_up.html", "/profile.php", "/ucp.php", "/account/register.php", "/join_form.php", "/tiki-register.php", "/YaBB.cgi/", "/YaBB.pl/", "/member/register", "/signup.php", "/blogs/load/recent", "/member/join.php", "/ieie/iei/ie.php", "/phpMyAdmin/scripts/setup.php", "/pma/scripts/setup.php", "/myadmin/scripts/setup.php"}
	for _, location := range bogus {
		web.Get(location, Hello)
	}

	bogusParam := []string{"/index.php", "/viewtopic.php"}
	for _, location := range bogusParam {
		web.Get(location, ParamExample)
	}
}
示例#19
0
func (srv *Server) Serve() {
	web.Get("/job/list", jobList)
	web.Get("/task/list", taskList)
	web.Get("/job/(.*)", jobGet)
	web.Post("/job", jobNew)
	web.Post("/job/run/(.*)", jobRun)
	web.Delete("/job/(.*)", jobRemove)
	web.Put("/job/(.*)", jobUpdate)

	addr, _ := globalCfg.ReadString("http_addr", ":9090")
	web.Run(addr)
}
示例#20
0
func (tte *TimeTableEngine) ServePages(basecp BaseCP, menuEntries MenuEntries) {
	timeTableCP := basecp(tte.state)

	timeTableCP.ContentTitle = "TimeTable"
	timeTableCP.ExtraCSSurls = append(timeTableCP.ExtraCSSurls, "/css/timetable.css")

	tvgf := DynamicMenuFactoryGenerator(menuEntries)
	tvg := tvgf(tte.state)

	web.Get("/timetable", tte.GenerateTimeTableRedirect())                                  // Redirect to /timeTable/main
	web.Get("/timetable/(.*)", timeTableCP.WrapWebHandle(tte.GenerateShowTimeTable(), tvg)) // Displaying timeTable pages
	web.Get("/css/timetable.css", tte.GenerateCSS(timeTableCP.ColorScheme))                 // CSS that is specific for timeTable pages
}
示例#21
0
文件: main.go 项目: napsy/goready
func main() {

	// Uncomment this to fill the database with dummy values
	/*err := InsertDeployments()
	if err != nil {
		fmt.Println(err)
		return
	}*/
	web.Get("/static", http.FileServer(http.Dir("static")))
	web.Get("/", GetIndex)
	web.Get("/deployments", GetDeployments)
	web.Run("0.0.0.0:9999")
}
示例#22
0
文件: admin.go 项目: jseaidou/monet
func AttachAdmin(url string) {
	web.Get(url+"unpublished/(\\d+)?", unpublishedList)
	web.Get(url+"posts/(\\d+)?", postList)
	app.GetPost(url+"posts/edit/(.*)", postEdit)
	web.Get(url+"posts/delete/(.*)", postDelete)
	app.GetPost(url+"posts/add/", postAdd)
	web.Post(url+"posts/preview/", postPreview)
	// pages
	app.GetPost(url+"pages/add/", pageAdd)
	app.GetPost(url+"pages/edit/(.*)", pageEdit)
	web.Post(url+"pages/preview/", pagePreview)
	web.Get(url+"pages/delete/(.*)", pageDelete)
	web.Get(url+"pages/(\\d+)?", pageList)
}
示例#23
0
文件: admin.go 项目: elimisteve/monet
func AttachAdmin(url string) {
	// auth
	web.Get(url+"login/", login)
	web.Post(url+"login/", login)
	web.Get(url+"logout/", logout)
	// users
	/*  too much unnecessary work?
	    web.Get(url + "users/", userList)
	    web.Get(url + "users/edit/(.*)", userEdit)
	    web.Get(url + "users/delete/(.*)", userDelete)
	    web.Get(url + "users/add/", userAdd)
	    web.Post(url + "users/add/", userAddPost)
	*/
	web.Get(url, adminIndex)
}
示例#24
0
func (ae *AdminEngine) ServePages(basecp BaseCP, menuEntries MenuEntries) {
	ae.serveSystem()

	state := ae.state

	adminCP := basecp(state)
	adminCP.ContentTitle = "Admin"
	adminCP.ExtraCSSurls = append(adminCP.ExtraCSSurls, "/css/admin.css")

	// template content generator
	tpvf := DynamicMenuFactoryGenerator(menuEntries)

	web.Get("/admin", adminCP.WrapSimpleContextHandle(GenerateAdminStatus(state), tpvf(state)))
	web.Get("/css/admin.css", ae.GenerateCSS(adminCP.ColorScheme))
}
示例#25
0
func (ce *ChatEngine) ServePages(basecp BaseCP, menuEntries MenuEntries) {
	chatCP := basecp(ce.state)
	chatCP.ContentTitle = "Chat"
	chatCP.ExtraCSSurls = append(chatCP.ExtraCSSurls, "/css/chat.css")

	tvgf := DynamicMenuFactoryGenerator(menuEntries)
	tvg := tvgf(ce.state)

	web.Get("/chat", chatCP.WrapSimpleContextHandle(ce.GenerateChatCurrentUser(), tvg))
	web.Post("/say", ce.GenerateSayCurrentUser())
	web.Get("/css/chat.css", ce.GenerateCSS(chatCP.ColorScheme))
	web.Post("/setchatlines", ce.GenerateSetChatLinesCurrentUser())
	// For debugging
	web.Get("/getchatlines", ce.GenerateGetChatLinesCurrentUser())
}
示例#26
0
文件: server.go 项目: xyproto/forum
func generateResourceRoutes(resource controllers.Controllers) {
	resourceString := controllers.FriendlyName(resource)

	models.SetupTable(resourceString)

	log.Printf(" - starting /%s routes generation\n", resourceString)
	web.Get("(?i)/"+resourceString+"/?", resource.Index)
	web.Get("(?i)/"+resourceString+"/(\\d*)", resource.Show)
	web.Get("(?i)/"+resourceString+"/new/?", resource.New)
	web.Get("(?i)/"+resourceString+"/(\\d*)", resource.Edit)

	web.Post("(?i)/"+resourceString+"/?", resource.Create)
	web.Put("(?i)/"+resourceString+"/(\\d*)", resource.Update)
	web.Delete("(?i)/"+resourceString+"/(\\d*)", resource.Delete)
	log.Printf(" - finished /%s routes generation\n", resourceString)
}
示例#27
0
// Routing for the archlinux.no webpage
// Admin, search and user management is already provided
func ServeArchlinuxNo(userState *permissions.UserState, jquerypath string) MenuEntries {
	cps := []ContentPage{
		*OverviewCP(userState, "/"),
		//*TextCP(userState, "/text"),
		*JQueryCP(userState, "/jquery"),
		*BobCP(userState, "/bob"),
		*CountCP(userState, "/counting"),
		*MirrorsCP(userState, "/mirrors"),
		*HelloCP(userState, "/feedback"),
		*LoginCP(ArchBaseCP, userState, "/login"),
		*RegisterCP(ArchBaseCP, userState, "/register"),
	}

	menuEntries := Cps2MenuEntries(cps)

	// template content generator
	tvgf := DynamicMenuFactoryGenerator(menuEntries)

	// TODO: Simplify ServeSearchPages to take fewer parameters
	ServeSearchPages(ArchBaseCP, userState, cps, ArchBaseCP(userState).ColorScheme, tvgf(userState))
	ServeSite(ArchBaseCP, userState, cps, tvgf, jquerypath)

	// "dynamic" pages
	// Makes helloSF handle the content for /hello/(.*) urls, but wrapped in a BaseCP with the title "Hello"
	web.Get("/hello/(.*)", ArchBaseTitleCP("Hello", userState).WrapWebHandle(helloHandle, tvgf(userState)))

	return menuEntries
}
示例#28
0
func main() {
	flag.Parse()
	web.Get("/", func() string {
		return "Hello World"
	})
	web.Run(":8080")
}
示例#29
0
// Uses a given SimpleContextHandle as the contents for the the ContentPage contents
func (cp *ContentPage) WrapSimpleContextHandle(sch webhandle.SimpleContextHandle, tvg webhandle.TemplateValueGenerator) webhandle.SimpleContextHandle {
	return func(ctx *web.Context) string {
		html, css := cp.Surround(sch(ctx), tvg(ctx))
		web.Get(cp.GeneratedCSSurl, css)
		return html
	}
}
示例#30
0
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")
}