mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
Currently any clients created through `NewApiWithClient` will make a HTTP request to the api, even if the multiaddress specifies TLS or (the deprecated multiaddr option) https. This commit addresses this by having NewApiWithClient iterate the available protocols for the multiaddress, specifying the URL proto as https if it finds TLS or HTTPS is specified. The default continues to be http for those multiaddresses that do not specify these options. Should resolve #176 This commit was moved from ipfs/go-ipfs-http-client@7e1de1f7cc |
||
|---|---|---|
| .. | ||
| api_test.go | ||
| api.go | ||
| apifile.go | ||
| block.go | ||
| dag.go | ||
| dht.go | ||
| errors_test.go | ||
| errors.go | ||
| key.go | ||
| name.go | ||
| object.go | ||
| path.go | ||
| pin.go | ||
| pubsub.go | ||
| README.md | ||
| request.go | ||
| requestbuilder.go | ||
| response.go | ||
| routing.go | ||
| swarm.go | ||
| unixfs.go | ||
go-ipfs-http-api
IPFS CoreAPI implementation using HTTP API
This package is experimental and subject to change. If you need to depend on something less likely to change, please use go-ipfs-api. If you'd like the latest and greatest features, please use this package.
Documentation
https://godoc.org/github.com/ipfs/go-ipfs-http-api
Example
Pin file on your local IPFS node based on its CID:
package main
import (
"context"
"fmt"
ipfsClient "github.com/ipfs/go-ipfs-http-client"
path "github.com/ipfs/interface-go-ipfs-core/path"
)
func main() {
// "Connect" to local node
node, err := ipfsClient.NewLocalApi()
if err != nil {
fmt.Printf(err)
return
}
// Pin a given file by its CID
ctx := context.Background()
cid := "bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku"
p := path.New(cid)
err = node.Pin().Add(ctx, p)
if err != nil {
fmt.Printf(err)
return
}
return
}
Contribute
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
Want to hack on IPFS?
License
MIT
