提交 b4fc0dba 作者: Matt Bell 提交者: Juan Batiz-Benet

cmd/ipfs: Added basic daemon command

上级 b499c90d
package main
import (
"net/http"
cmds "github.com/jbenet/go-ipfs/commands"
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
)
var Daemon = &cmds.Command{
Options: []cmds.Option{},
Help: "TODO",
Subcommands: map[string]*cmds.Command{},
Run: daemonFunc,
}
func daemonFunc(req cmds.Request, res cmds.Response) {
handler := cmdsHttp.Handler{}
http.Handle(cmdsHttp.ApiPath+"/", handler)
// TODO: load listen address/port from config/options
err := http.ListenAndServe(":8080", nil)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
// TODO: log to indicate that we are now listening
}
......@@ -9,11 +9,6 @@ var Root = &cmds.Command{
Options: commands.Root.Options,
Help: commands.Root.Help,
Subcommands: map[string]*cmds.Command{
"test": &cmds.Command{
Run: func(req cmds.Request, res cmds.Response) {
v := "hello, world"
res.SetValue(v)
},
},
"daemon": Daemon,
},
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论