diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go new file mode 100644 index 000000000..b294cdf98 --- /dev/null +++ b/cmd/ipfs/daemon.go @@ -0,0 +1,27 @@ +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 +} diff --git a/cmd/ipfs/root.go b/cmd/ipfs/root.go index 154381cbb..bd84f43a8 100644 --- a/cmd/ipfs/root.go +++ b/cmd/ipfs/root.go @@ -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, }, }