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())) } }
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) }