本文整理匯總了Golang中github.com/hoisie/web.Server.Run方法的典型用法代碼示例。如果您正苦於以下問題:Golang Server.Run方法的具體用法?Golang Server.Run怎麽用?Golang Server.Run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hoisie/web.Server
的用法示例。
在下文中一共展示了Server.Run方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Start
func Start(state interfaces.IState) {
var server *web.Server
if Servers == nil {
Servers = make(map[int]*web.Server)
}
if Servers[state.GetPort()] == nil {
server = web.NewServer()
Servers[state.GetPort()] = server
server.Env["state"] = state
server.Post("/v1/factoid-submit/?", HandleFactoidSubmit)
server.Post("/v1/commit-chain/?", HandleCommitChain)
server.Post("/v1/reveal-chain/?", HandleRevealChain)
server.Post("/v1/commit-entry/?", HandleCommitEntry)
server.Post("/v1/reveal-entry/?", HandleRevealEntry)
server.Get("/v1/directory-block-head/?", HandleDirectoryBlockHead)
server.Get("/v1/get-raw-data/([^/]+)", HandleGetRaw)
server.Get("/v1/directory-block-by-keymr/([^/]+)", HandleDirectoryBlock)
server.Get("/v1/entry-block-by-keymr/([^/]+)", HandleEntryBlock)
server.Get("/v1/entry-by-hash/([^/]+)", HandleEntry)
server.Get("/v1/chain-head/([^/]+)", HandleChainHead)
server.Get("/v1/entry-credit-balance/([^/]+)", HandleEntryCreditBalance)
server.Get("/v1/factoid-balance/([^/]+)", HandleFactoidBalance)
server.Get("/v1/factoid-get-fee/", HandleGetFee)
log.Print("Starting server")
go server.Run(fmt.Sprintf("localhost:%d", state.GetPort()))
}
}
示例2: main
func main() {
var server1 web.Server
var server2 web.Server
server1.Get("/(.*)", hello1)
go server1.Run("0.0.0.0:9999")
server2.Get("/(.*)", hello2)
go server2.Run("0.0.0.0:8999")
<-make(chan int)
}