kubo/client/httpapi
Ross Jones 7d8262307c fix: use https URI when multiaddress specifies tls (#177)
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
2023-05-15 18:18:51 +02:00
..
api_test.go fix: use https URI when multiaddress specifies tls (#177) 2023-05-15 18:18:51 +02:00
api.go fix: use https URI when multiaddress specifies tls (#177) 2023-05-15 18:18:51 +02:00
apifile.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
block.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
dag.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
dht.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
errors_test.go correctness: only match CIDs matching go-cid.Cid.String output 2022-04-05 20:14:40 +02:00
errors.go chore: remove unused linter directives 2022-10-01 17:37:23 +02:00
key.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
name.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
object.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
path.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
pin.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
pubsub.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
README.md docs: adding example of connection and pinning to README (#173) 2023-03-28 12:38:24 +02:00
request.go feed through context 2019-04-04 00:37:23 -07:00
requestbuilder.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
response.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
routing.go chore: bumps for Kubo 0.18 and Routing API with stub for Put 2023-02-10 03:36:15 +01:00
swarm.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00
unixfs.go chore: migrate from go-libipfs to boxo 2023-04-18 15:31:48 +02:00

go-ipfs-http-api

standard-readme compliant GoDoc

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