-
-
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
gateway: use core api for serving GET/HEAD/POST #3244
Conversation
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.
One comment, then LGTM
defer func() { | ||
if r := recover(); r != nil { | ||
log.Error("A panic occurred in the gateway handler!") | ||
log.Error(r) | ||
debug.PrintStack() | ||
cancel() |
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.
no need for the cancel here. Its deferred as well and will be run on a panic
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.
} | ||
}() | ||
|
||
if i.config.Writable { | ||
switch r.Method { | ||
case "POST": | ||
i.postHandler(w, r) | ||
i.postHandler(ctx, w, r) |
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.
<3
@lgierth progress here? tests seem unhappy, i'd rebase them on master |
d18ed3c
to
4841153
Compare
4841153
to
7017c0a
Compare
I've rebased this PR back on master and closed the other one. Waiting for tests. |
// Version() CoreVersion | ||
// } | ||
|
||
type Link struct { |
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.
could this just rebind ipldnode.Link? (fine if not for now, but maybe later?)
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.
could this just rebind ipldnode.Link? (fine if not for now, but maybe later?)
updated
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.
One small nitpick, then LGTM
if !ok { | ||
webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) | ||
return | ||
} 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.
drop the 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.
One of the conditionals above doesn't return (else if err == coreiface.ErrIsDir
), so we'd be calling nil.Close()
. This piece first tries a reader, then lists links if it's a directory.
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.
Oooooooh, okay. Thats mildly confusing then... But i guess it works.
return nil, err | ||
} | ||
|
||
_, ok := dagnode.(*mdag.ProtoNode) |
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.
no longer need this cast. NewDagReader takes the ipldnode.Node interface
} | ||
|
||
func (api *UnixfsAPI) Add(ctx context.Context, r io.Reader) (*cid.Cid, error) { | ||
k, err := coreunix.AddWithContext(ctx, api.node, r) |
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 AddWithContent should return a cid? not sure
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.
Agreed, but not in this PR. Happy to convert the unixfs package to using CIDs in another PR.
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.
Agreed, but not in this PR. Happy to convert the unixfs package to using CIDs in another PR.
Eh I meant coreunix. Maybe we can just rip coreunix out.
select { | ||
case <-clientGone: | ||
case <-ctx.Done(): | ||
} |
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.
The cancel got dropped from here. Thats important
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.
wooops. thanks so much for spotting this.
e2c6410
to
d968711
Compare
addressed:
Filed an issue for the unrelated teamcity failure -- #3341 |
@lgierth whats needed here? more review? |
I think it's good to go, I addressed the remaining feedback |
License: MIT Signed-off-by: Lars Gierth <[email protected]>
License: MIT Signed-off-by: Lars Gierth <[email protected]>
License: MIT Signed-off-by: Lars Gierth <[email protected]>
License: MIT Signed-off-by: Lars Gierth <[email protected]>
License: MIT Signed-off-by: Lars Gierth <[email protected]>
License: MIT Signed-off-by: Lars Gierth <[email protected]>
d968711
to
f610e19
Compare
Ping -- I think this is good to go |
Thanks @lgierth ! |
gateway: use core api for serving GET/HEAD/POST This commit was moved from ipfs/kubo@aae9eb7
Basing this PR on the feat/coreapi branch just so the diff is more obvious.