提交 8eb95faf 作者: verokarhu

moved http to server/http and implemented serve http subcommand

上级 0a25b64f
......@@ -43,7 +43,7 @@ Tool commands:
Advanced Commands:
mount Mount an ipfs read-only mountpoint.
serve Serve an http gateway into ipfs.
serve Serve an interface to ipfs.
Use "ipfs help <command>" for more information about a command.
```
......
......@@ -35,7 +35,7 @@ Tool commands:
Advanced Commands:
mount Mount an ipfs read-only mountpoint.
serve Serve an http gateway into ipfs.
serve Serve an interface to ipfs.
Use "ipfs help <command>" for more information about a command.
`,
......
......@@ -5,23 +5,32 @@ import (
"fmt"
"github.com/gonuts/flag"
"github.com/jbenet/commander"
h "github.com/jbenet/go-ipfs/http"
h "github.com/jbenet/go-ipfs/server/http"
)
var cmdIpfsServe = &commander.Command{
UsageLine: "serve",
Short: "Serve an interface to ipfs",
Subcommands: []*commander.Command{
cmdIpfsServeHttp,
},
Flag: *flag.NewFlagSet("ipfs-serve", flag.ExitOnError),
}
var cmdIpfsServeHttp = &commander.Command{
UsageLine: "http",
Short: "Serve an HTTP API",
Long: `ipfs serve - Serve an http gateway into ipfs.`,
Run: serveCmd,
Flag: *flag.NewFlagSet("ipfs-serve", flag.ExitOnError),
Long: `ipfs serve http - Serve an http gateway into ipfs.`,
Run: serveHttpCmd,
Flag: *flag.NewFlagSet("ipfs-serve-http", flag.ExitOnError),
}
func init() {
cmdIpfsServe.Flag.Uint("port", 8080, "Port number")
cmdIpfsServe.Flag.String("hostname", "localhost", "Hostname")
cmdIpfsServeHttp.Flag.Uint("port", 8080, "Port number")
cmdIpfsServeHttp.Flag.String("hostname", "localhost", "Hostname")
}
func serveCmd(c *commander.Command, _ []string) error {
func serveHttpCmd(c *commander.Command, _ []string) error {
port := c.Flag.Lookup("port").Value.Get().(uint)
if port < 1 || port > 65535 {
return errors.New("invalid port number")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论