-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
httpGw: make /tcp/0 work #1287
httpGw: make /tcp/0 work #1287
Conversation
@@ -67,6 +68,17 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler | |||
return err | |||
} | |||
|
|||
host, port, err := net.SplitHostPort(list.Addr().String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a helper somewhere to construct a multiaddr form a found it..net.Addr
directly?
if err != nil { | ||
res.SetError(err, cmds.ErrNormal) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure it's ok to move this check down? not sure if it was up above for a reason (i.e. bail out early before something else)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm.. that's a good point - my idea was to group the bring-up of fuse mount, gateway and API. I can revert it if you prefer the early-error out. I'm not sure if daemon startup failure something you want to optimizer over clarity for though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with you. if there's no error here, let's move it down.
89f29a8
to
002b6b9
Compare
rebased |
002b6b9
to
9610604
Compare
rebased (2) |
Running tests on all commits |
9a2bc59
to
d8c11a5
Compare
squashed and rebased onto master. i reorderd it to do api first, gateway 2nd and had to change the way |
@cryptix would you mind splitting this into function for the steps? one big function is scary to edit because not clear what is required to be in that order. functions are nicer because smaller units of work are easier to reason about. you have this paged into your mind right now and are best suited for it. |
fef207b
to
2d87eaa
Compare
rebased for fun and test results |
563760b
to
cea5aa2
Compare
@jbenet i reworked the helper to not goroutine until necessary, this way they don't race on writing to stdout (this caused the weird 'daemon output not okay' test faults i belive) RFM if its fine with you. |
if len(cfg.Gateway.RootRedirect) > 0 { | ||
rootRedirect = corehttp.RedirectOption("", cfg.Gateway.RootRedirect) | ||
// mountHTTPapi collects options, creates listener, prints status message and starts serving requests | ||
func mountHTTPapi(req cmds.Request) (error, <-chan error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling it mount
might confuse things with fuse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm.. yea.. open
or listenAndServe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe serveHTTPApi
} | ||
|
||
// mountHTTPgw collects options, creates listener, prints status message and starts serving requests | ||
func mountHTTPgw(req cmds.Request) (error, <-chan error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serveHTTPGateway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(should it be serveHttpGateway
? dont recall what's go idiomatic)
@cryptix more comments o/ |
also splits api, gw and fuse bring up into helper functions
cea5aa2
to
4b337bb
Compare
rebased and addressed comments |
LGTM i'll merge after tests run |
httpGw: make /tcp/0 work This commit was moved from ipfs/kubo@217fe26
Prints out the chosen port and puts it into the config so the cli works over it too.
Fixes #1288