Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
bb924cab
Commit
bb924cab
authored
10 years ago
by
verokarhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add port flag to serve
parent
0427d1ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
cmd/ipfs/serve.go
cmd/ipfs/serve.go
+11
-1
http/http.go
http/http.go
+1
-1
No files found.
cmd/ipfs/serve.go
View file @
bb924cab
package
main
import
(
"errors"
"github.com/gonuts/flag"
"github.com/jbenet/commander"
h
"github.com/jbenet/go-ipfs/http"
...
...
@@ -14,11 +15,20 @@ var cmdIpfsServe = &commander.Command{
Flag
:
*
flag
.
NewFlagSet
(
"ipfs-serve"
,
flag
.
ExitOnError
),
}
func
init
()
{
cmdIpfsServe
.
Flag
.
Uint
(
"port"
,
80
,
"Port number"
)
}
func
serveCmd
(
c
*
commander
.
Command
,
_
[]
string
)
error
{
port
:=
c
.
Flag
.
Lookup
(
"port"
)
.
Value
.
Get
()
.
(
uint
)
if
port
<
1
||
port
>
65535
{
return
errors
.
New
(
"invalid port number"
)
}
n
,
err
:=
localNode
()
if
err
!=
nil
{
return
err
}
return
h
.
Serve
(
"127.0.0.1"
,
80
,
n
)
return
h
.
Serve
(
"127.0.0.1"
,
port
,
n
)
}
This diff is collapsed.
Click to expand it.
http/http.go
View file @
bb924cab
...
...
@@ -24,7 +24,7 @@ func (i *ipfsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt
.
Fprintf
(
w
,
"%s"
,
nd
.
Data
)
}
func
Serve
(
host
string
,
port
uint
16
,
node
*
core
.
IpfsNode
)
error
{
func
Serve
(
host
string
,
port
uint
,
node
*
core
.
IpfsNode
)
error
{
r
:=
mux
.
NewRouter
()
r
.
PathPrefix
(
"/"
)
.
Handler
(
&
ipfsHandler
{
node
})
.
Methods
(
"GET"
)
http
.
Handle
(
"/"
,
r
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment