1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-17 23:16:11 +08:00

rename Libp2pGatewayOption and hard code its gateway configuration

This commit is contained in:
Adin Schmahmann
2023-08-31 03:51:48 -04:00
parent 9d32f71e22
commit bc6bee1585
2 changed files with 10 additions and 8 deletions

View File

@ -911,7 +911,7 @@ const gatewayProtocolID protocol.ID = "/ipfs/gateway" // FIXME: specify https://
func serveTrustlessGatewayOverLibp2p(cctx *oldcmds.Context) (<-chan error, error) {
opts := []corehttp.ServeOption{
corehttp.MetricsCollectionOption("libp2p-gateway"),
corehttp.TrustlessGatewayOption(),
corehttp.Libp2pGatewayOption(),
corehttp.VersionOption(),
}

View File

@ -76,13 +76,8 @@ func VersionOption() ServeOption {
}
}
func TrustlessGatewayOption() ServeOption {
func Libp2pGatewayOption() ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
config, err := getGatewayConfig(n)
if err != nil {
return nil, err
}
bserv := blockservice.New(n.Blocks.Blockstore(), offline.Exchange(n.Blocks.Blockstore()))
backend, err := gateway.NewBlocksBackend(bserv)
@ -90,7 +85,14 @@ func TrustlessGatewayOption() ServeOption {
return nil, err
}
handler := gateway.NewHandler(config, &offlineGatewayErrWrapper{gwimpl: backend})
gwConfig := gateway.Config{
DeserializedResponses: false,
NoDNSLink: true,
PublicGateways: nil,
Menu: nil,
}
handler := gateway.NewHandler(gwConfig, &offlineGatewayErrWrapper{gwimpl: backend})
handler = otelhttp.NewHandler(handler, "Libp2p-Gateway")
mux.Handle("/ipfs/", handler)