From d848c915591cec844086d329f8e7d6fce796e251 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 22 Apr 2022 01:05:30 +0200 Subject: [PATCH] chore: remove Gateway.PathPrefixes Closes #7702 --- cmd/ipfs/daemon.go | 2 +- config/gateway.go | 20 +++----------------- core/corehttp/gateway.go | 10 ++++------ docs/config.md | 36 +----------------------------------- 4 files changed, 9 insertions(+), 59 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 32cff04ef2c..6fe94c1064a 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -800,7 +800,7 @@ func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, e } if len(cfg.Gateway.PathPrefixes) > 0 { - log.Error("Support for X-Ipfs-Gateway-Prefix and Gateway.PathPrefixes is deprecated and will be removed in the next release. Please comment on the issue if you're using this feature: https://github.com/ipfs/go-ipfs/issues/7702") + log.Fatal("Support for custom Gateway.PathPrefixes was removed: https://github.com/ipfs/go-ipfs/issues/7702") } node, err := cctx.ConstructNode() diff --git a/config/gateway.go b/config/gateway.go index e85cda98688..c1cd95caa34 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -8,7 +8,7 @@ type GatewaySpec struct { // UseSubdomains indicates whether or not this gateway uses subdomains // for IPFS resources instead of paths. That is: http://CID.ipfs.GATEWAY/... // - // If this flag is set, any /ipns/$id and/or /ipfs/$id paths in PathPrefixes + // If this flag is set, any /ipns/$id and/or /ipfs/$id paths in Paths // will be permanently redirected to http://$id.[ipns|ipfs].$gateway/. // // We do not support using both paths and subdomains for a single domain @@ -35,22 +35,8 @@ type Gateway struct { // writing is done through the API, not the gateway. Writable bool - // PathPrefixes is an array of acceptable url paths that a client can - // specify in X-Ipfs-Path-Prefix header. - // - // The X-Ipfs-Path-Prefix header is used to specify a base path to prepend - // to links in directory listings and for trailing-slash redirects. It is - // intended to be set by a frontend http proxy like nginx. - // - // Example: To mount blog.ipfs.io (a DNSLink site) at ipfs.io/blog - // set PathPrefixes to ["/blog"] and nginx config to translate paths - // and pass Host header (for DNSLink): - // location /blog/ { - // rewrite "^/blog(/.*)$" $1 break; - // proxy_set_header Host blog.ipfs.io; - // proxy_set_header X-Ipfs-Gateway-Prefix /blog; - // proxy_pass http://127.0.0.1:8080; - // } + // PathPrefixes was removed: https://github.com/ipfs/go-ipfs/issues/7702 + // TODO: can we remove it from this struct? PathPrefixes []string // FIXME: Not yet implemented diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 2e794b53ffc..e93d34d07e9 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -16,9 +16,8 @@ import ( ) type GatewayConfig struct { - Headers map[string][]string - Writable bool - PathPrefixes []string + Headers map[string][]string + Writable bool } // A helper function to clean up a set of headers: @@ -89,9 +88,8 @@ func GatewayOption(writable bool, paths ...string) ServeOption { }, headers[ACEHeadersName]...)) var gateway http.Handler = newGatewayHandler(GatewayConfig{ - Headers: headers, - Writable: writable, - PathPrefixes: cfg.Gateway.PathPrefixes, + Headers: headers, + Writable: writable, }, api) gateway = otelhttp.NewHandler(gateway, "Gateway.Request") diff --git a/docs/config.md b/docs/config.md index 519a7c10546..014deee1399 100644 --- a/docs/config.md +++ b/docs/config.md @@ -52,7 +52,6 @@ config file at runtime. - [`Gateway.HTTPHeaders`](#gatewayhttpheaders) - [`Gateway.RootRedirect`](#gatewayrootredirect) - [`Gateway.Writable`](#gatewaywritable) - - [`Gateway.PathPrefixes`](#gatewaypathprefixes) - [`Gateway.PublicGateways`](#gatewaypublicgateways) - [`Gateway.PublicGateways: Paths`](#gatewaypublicgateways-paths) - [`Gateway.PublicGateways: UseSubdomains`](#gatewaypublicgateways-usesubdomains) @@ -658,40 +657,7 @@ Type: `bool` ### `Gateway.PathPrefixes` -**DEPRECATED:** see [go-ipfs#7702](https://github.com/ipfs/go-ipfs/issues/7702) - - - -Default: `[]` - -Type: `array[string]` +**REMOVED:** see [go-ipfs#7702](https://github.com/ipfs/go-ipfs/issues/7702) ### `Gateway.PublicGateways`