1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 03:28:25 +08:00

cmd/ipfs: Added basic daemon command

This commit is contained in:
Matt Bell
2014-10-24 15:13:34 -07:00
committed by Juan Batiz-Benet
parent b499c90db3
commit b4fc0dba96
2 changed files with 28 additions and 6 deletions

27
cmd/ipfs/daemon.go Normal file
View File

@ -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
}

View File

@ -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,
},
}