gateway: use core api for serving GET/HEAD/POST#3244
Conversation
core/corehttp/gateway_handler.go
Outdated
| log.Error("A panic occurred in the gateway handler!") | ||
| log.Error(r) | ||
| debug.PrintStack() | ||
| cancel() |
There was a problem hiding this comment.
no need for the cancel here. Its deferred as well and will be run on a panic
| switch r.Method { | ||
| case "POST": | ||
| i.postHandler(w, r) | ||
| i.postHandler(ctx, w, r) |
|
@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. |
core/coreapi/interface/interface.go
Outdated
| // Version() CoreVersion | ||
| // } | ||
|
|
||
| type Link struct { |
There was a problem hiding this comment.
could this just rebind ipldnode.Link? (fine if not for now, but maybe later?)
There was a problem hiding this comment.
could this just rebind ipldnode.Link? (fine if not for now, but maybe later?)
updated
whyrusleeping
left a comment
There was a problem hiding this comment.
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.
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.
Oooooooh, okay. Thats mildly confusing then... But i guess it works.
core/coreapi/unixfs.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| _, ok := dagnode.(*mdag.ProtoNode) |
There was a problem hiding this comment.
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.
maybe AddWithContent should return a cid? not sure
There was a problem hiding this comment.
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.
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.
The cancel got dropped from here. Thats important
There was a problem hiding this comment.
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 <larsg@systemli.org>
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
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.