tendermint/rpc/http_server.go

24 lines
530 B
Go
Raw Normal View History

2014-11-27 04:04:07 -08:00
package rpc
import (
"fmt"
"net/http"
. "github.com/tendermint/tendermint/config"
2014-12-29 18:09:06 -08:00
. "github.com/tendermint/tendermint/common"
2014-11-27 04:04:07 -08:00
)
func StartHTTPServer() {
2014-11-30 18:31:44 -08:00
http.HandleFunc("/block", BlockHandler)
2014-11-27 04:04:07 -08:00
// Serve HTTP on localhost only.
// Let something like Nginx handle HTTPS connections.
address := fmt.Sprintf("127.0.0.1:%v", Config.RPC.HTTPPort)
2014-12-29 18:09:06 -08:00
log.Info(Fmt("Starting RPC HTTP server on http://%s", address))
2014-11-27 04:04:07 -08:00
go func() {
2014-12-29 18:09:06 -08:00
log.Crit("%v", http.ListenAndServe(address, RecoverAndLogHandler(http.DefaultServeMux)))
2014-11-27 04:04:07 -08:00
}()
}