jsonrpc: Work with browsers

This commit is contained in:
Łukasz Magiera
2019-07-24 19:09:00 +02:00
parent c7b2bf8100
commit 93a8ee11db
2 changed files with 23 additions and 3 deletions
+8 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/filecoin-project/go-lotus/api"
lcli "github.com/filecoin-project/go-lotus/cli"
"github.com/filecoin-project/go-lotus/lib/auth"
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
"github.com/filecoin-project/go-lotus/node"
"github.com/filecoin-project/go-lotus/node/repo"
@@ -72,7 +73,13 @@ var runCmd = &cli.Command{
rpcServer := jsonrpc.NewServer()
rpcServer.Register("Filecoin", api.PermissionedStorMinerAPI(minerapi))
http.Handle("/rpc/v0", rpcServer)
ah := &auth.Handler{
Verify: minerapi.AuthVerify,
Next: rpcServer.ServeHTTP,
}
http.Handle("/rpc/v0", ah)
return http.ListenAndServe("127.0.0.1:"+cctx.String("api"), http.DefaultServeMux)
},
}