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
feat(gateway): _redirects file support #8890
base: master
Are you sure you want to change the base?
feat(gateway): _redirects file support #8890
Conversation
c8a2631
to
3853b36
Compare
|
@lidel When you have time, gentle bump on getting your feedback to the comments above. I really appreciate the time and feedback you've given me already. At this point I have what feels like the right MVP functionality working ( Also, related to your go-redirects comments... it feels to me like we should not use a library dedicated to parsing Netlify's _redirect file, and instead have our own library whose specific goal is to support the functionality in the redirect IPFS spec (to be written). For now I'm thinking this is essentially a fork of go-redirects that only supports If you disagree and want me to stick with a repo that specifically supports Netlify's syntax, I still had to fork the repo since it is no longer maintained, and it seems to me there wouldn't be any reason to add all the existing Netlify parsing logic right away, since the MVP won't support all of those features anyway. For convenience for anyone wanting to evaluate the changes... |
24d60bd
to
19d070b
Compare
|
FYI, I'll be out for a few weeks but will be checking email in case there is any PR feedback. I'm sure there will be things to address but I'm going to mark this as ready for review now. |
|
After some discussion with @b5 and @dignifiedquire, I'm leaning toward pulling out forced redirect support to avoid a performance hit for anything other than non-existent paths (i.e. read |
|
Review status... @lidel is wrapping up specs for existing gateway functionality and then hopes to get to this, possibly next week or the week after. |
First, thank you for your patience @justincjohnson
I will be OOO Thu-Fri due to Holiday, and will do proper review of go code in this PR when I am back, but to get things going, quick feedback:
Moving go-ipfs-redirects to ipfs org
Good call on making a dedicated lib.
If you add me as Admin to https://github.com/justincjohnson/go-ipfs-redirects i'll move it to ipfs org + ensure you still have your permissions.
Creating RFC with specs
We want this to be a part of web gateway specs, and not just go-ipfs feature.
Good news is that we now have all the pieces in place to do the proper spec work:
- HTTP Gateway specs that describe state in go-ipfs 0.13 are in ipfs/specs#283 (still gathering feedback, but will be merged soon)
- Light RFC process for IPFS specs is proposed in ipfs/specs#286 and ipfs/specs#289
Do you mind opening a PR against HTTP Gateway specs from ipfs/specs#283 that adds:
http-gateways/REDIRECTS_FILE.mddescribing this feature- Include a copy of
RFC/0000-template.mdfrom ipfs/specs#289 describing motivation for adding_redirectssupport.- we want this to be a lightweight process, so a single paragraph is enough to get the discussion started :)
When we have ipfs/specs PR with RFC,
I'll ping folks from other implementations to take a look and provide feedback, to ensure they are onboard too
Thanks!
992c1cc
to
c31f4cc
Compare
1a8a2ad
to
2ab5075
Compare
Thank you for your angelic patience @justincjohnson
I did the first pass review of this along with IPIP (specifications) at ipfs/specs#290 – some questions / asks apply to both – details inline.
General ask for this PR is to rebase on top of latest master to include new tests added in past few weeks.
| // Check for root path. | ||
| _, err = i.api.Block().Get(r.Context(), rootPath) | ||
| if err != nil { | ||
| return nil | ||
| } |
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.
What is the purpose of this check?
| // Returns the root CID Path for the given path | ||
| func getRootPath(path string) (ipath.Path, error) { | ||
| if isIpfsPath(path) { | ||
| parts := strings.Split(path, "/") | ||
| return ipath.New(gopath.Join(ipfsPathPrefix, parts[2])), nil | ||
| } | ||
|
|
||
| if isIpnsPath(path) { | ||
| parts := strings.Split(path, "/") | ||
| return ipath.New(gopath.Join(ipnsPathPrefix, parts[2])), nil | ||
| } |
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.
nit: if you switch path from string to contentPath ipath.Path, then you will be able to read namespace via contentPath.Namespace() and simplify this
…rg once officially moved.
72b16a4
to
da34b51
Compare
This PR implements ipfs/specs#290.
Details
Now that #8885 has landed, I've moved my refactored😅
_redirectschanges here from #8816. This is on my personal account now, so the CircleCI permission issues should be resolved.@lidel, as mentioned at #8816 (comment), there are some challenges with trying to fully move
_redirectslogic out ofgateway_handler.goas you requested. The changes in this PR aren't ready (full review not needed yet), but would you be able to take a look and let me know if you approve of how I've split code intohandleUnixfsPathResolutionandhandleNonUnixfsPathResolution?Also, note that I've intentionally not moved 404 related functions from
gateway_handler.gotogateway_handler_unixfs__redirects.goyet, to avoid extra PR noise.