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:

committed by
Juan Batiz-Benet

parent
b499c90db3
commit
b4fc0dba96
27
cmd/ipfs/daemon.go
Normal file
27
cmd/ipfs/daemon.go
Normal 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
|
||||
}
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user