當前位置: 首頁>>代碼示例>>Golang>>正文


Golang rpc.HandleHTTP函數代碼示例

本文整理匯總了Golang中rpc.HandleHTTP函數的典型用法代碼示例。如果您正苦於以下問題:Golang HandleHTTP函數的具體用法?Golang HandleHTTP怎麽用?Golang HandleHTTP使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了HandleHTTP函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {

	var err os.Error

	// Pull in command line options or defaults if none given
	flag.Parse()

	f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
	if err == nil {
		defer f.Close()
		log.SetOutput(f)
	}

	skylib.Setup(sName)

	homeTmpl = template.MustParse(homeTemplate, nil)
	respTmpl = template.MustParse(responseTemplate, nil)

	http.HandleFunc("/", homeHandler)
	http.HandleFunc("/new", submitHandler)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	err = http.ListenAndServe(portString, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err.String())
	}
}
開發者ID:repos-go,項目名稱:skynet,代碼行數:30,代碼來源:web.go

示例2: main

func main( )
{
	rpc.HandleHTTP();

	l, _ := net.Listen("tcp", ":8089");
	http.Serve(l, http.HandlerFunc( handleRequest ) );
}
開發者ID:nkostelnik,項目名稱:learning,代碼行數:7,代碼來源:main.go

示例3: main

func main() {
	// Pull in command line options or defaults if none given
	flag.Parse()

	f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
	if err == nil {
		defer f.Close()
		log.SetOutput(f)
	}

	skylib.Setup(sName)

	homeTmpl = template.MustParse(homeTemplate, nil)
	respTmpl = template.MustParse(responseTemplate, nil)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	stack := new(mango.Stack)
	stack.Address = portString

	routes := make(map[string]mango.App)
	routes["/"] = homeHandler
	routes["/new"] = submitHandler
	stack.Middleware(mango.Routing(routes))
	stack.Run(nil)
}
開發者ID:paulbellamy,項目名稱:skynet,代碼行數:28,代碼來源:mangoInitiator.go

示例4: main

func main() {

	// Pull in command line options or defaults if none given
	flag.Parse()

	f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
	if err == nil {
		defer f.Close()
		log.SetOutput(f)
	}

	skylib.Setup(sName)

	r := NewGetUserDataService()

	rpc.Register(r)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	l, e := net.Listen("tcp", portString)
	if e != nil {
		log.Fatal("listen error:", e)
	}

	log.Println("Starting server")
	http.Serve(l, nil)

}
開發者ID:paulbellamy,項目名稱:skynet,代碼行數:30,代碼來源:service.go

示例5: Serve

// At the moment, this can start more than one Server on the same
// port, which could be a problem.
func (self *RpcService) Serve(done chan bool) {
	portString := fmt.Sprintf("%s:%d", self.IPAddress, self.Port)
	log.Println(portString)

	l, e := net.Listen("tcp", portString)
	if e != nil {
		log.Fatal("listen error:", e)
	}
	defer l.Close()

	switch self.Protocol {
	default:
		rpc.HandleHTTP() // Seems safe to call multiple times, but must
		// that precede net.Listen()?
		log.Println("Starting http server")
		http.Serve(l, nil)
	case "json":
		log.Println("Starting jsonrpc server")
		for {
			conn, err := l.Accept()
			if err != nil {
				panic(err.String())
			}
			jsonrpc.ServeConn(conn)
		}
	}
	done <- true // This may never occur.
}
開發者ID:andradeandrey,項目名稱:skynet,代碼行數:30,代碼來源:rpcservice.go

示例6: main

// The Router application registers RPC listeners to accept from the initiators
// then registers RPC clients to each of the external services it may call.
func main() {

	var err os.Error

	// Pull in command line options or defaults if none given
	flag.Parse()

	f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
	if err == nil {
		defer f.Close()
		log.SetOutput(f)
	}

	skylib.Setup("Watcher.Generic") // Change this to be more descriptive

	rpc.HandleHTTP()

	go monitorServices()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	l, e := net.Listen("tcp", portString)
	if e != nil {
		log.Fatal("listen error:", e)
	}
	log.Println("Starting server")
	http.Serve(l, nil)

}
開發者ID:repos-go,項目名稱:skynet,代碼行數:31,代碼來源:generic.go

示例7: main

func main() {
	flag.Parse()
	rpc.Register(server)
	rpc.HandleHTTP()
	http.HandleFunc("/", Static)
	http.HandleFunc("/get", Get)
	http.ListenAndServe(*listenAddr, nil)
}
開發者ID:andradeandrey,項目名稱:stat,代碼行數:8,代碼來源:stats.go

示例8: serveHTTP

// rpc over HTTP
func serveHTTP(addr string) {
	rpc.HandleHTTP()

	l, err := net.Listen("tcp", addr)
	if err != nil {
		log.Fatal(err)
	}
	http.Serve(l, nil)
}
開發者ID:nathankerr,項目名稱:negotiation,代碼行數:10,代碼來源:server.go

示例9: main

func main() {
	reg := NewReg()
	rpc.RegisterName(registry.Name, reg)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":"+strconv.Itoa(registry.Port))
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
}
開發者ID:Altece,項目名稱:Go-Go-Gadget-Repo,代碼行數:10,代碼來源:regserver.go

示例10: main

func main() {
	arith := new(arith.Arith)
	rpc.Register(arith)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Exit("listen error: ", e)
	}
	http.Serve(l, nil)
}
開發者ID:tokuhirom,項目名稱:go-examples,代碼行數:10,代碼來源:server.go

示例11: server

func server() {
	ps := new(ProcessStarter)
	rpc.Register(ps)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Exit("listen error:", e)
	}
	go http.Serve(l, nil)
}
開發者ID:psychobob666,項目名稱:MediaEncodingCluster,代碼行數:10,代碼來源:mainrpc.go

示例12: RunServer

func RunServer(addr string) {
	self := new(Server).Init()
	rpc.Register(self)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", addr)
	if e != nil {
		log.Exit("listen error: ", e)
	}
	http.Serve(l, nil)
}
開發者ID:ike-dai,項目名稱:go-simple-kvs,代碼行數:10,代碼來源:kvs.go

示例13: main

//Starts the server
func main() {
	md := NewMatrixDatabase()
	rpc.Register(md)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
}
開發者ID:Altece,項目名稱:Go-Go-Gadget-Repo,代碼行數:11,代碼來源:matrixserver.go

示例14: main

func main() {
	flag.Parse()
	t := &LunchTracker{NewPoll()}
	rpc.Register(t)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":"+strconv.Uitoa(*port))
	if e != nil {
		log.Exit("listen error:", e)
	}
	http.Serve(l, nil)
}
開發者ID:PrincessJessie,項目名稱:Go2Lunch,代碼行數:11,代碼來源:server.go

示例15: main

func main() {
	sfs := new(SFS)
	status := new(Status)
	Init(status)
	rpc.Register(sfs)
	rpc.HandleHTTP()

	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
	fmt.Println("done")
}
開發者ID:alangenfeld,項目名稱:cs639,代碼行數:14,代碼來源:chunkServerE.go


注:本文中的rpc.HandleHTTP函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。