kubo/client/httpapi/block.go
Łukasz Magiera 6c927fd962 Partial ipld node impl
This commit was moved from ipfs/go-ipfs-http-client@df916c7849
2018-11-06 14:41:45 +01:00

41 lines
988 B
Go

package httpapi
import (
"context"
"io"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
)
type BlockAPI HttpApi
func (api *BlockAPI) Put(ctx context.Context, r io.Reader, opts ...options.BlockPutOption) (iface.BlockStat, error) {
return nil, ErrNotImplemented
}
func (api *BlockAPI) Get(ctx context.Context, p iface.Path) (io.Reader, error) {
resp, err := api.core().request("block/get", p.String()).Send(context.Background())
if err != nil {
return nil, err
}
//TODO: is close on the reader enough?
//defer resp.Close()
//TODO: make blockApi return ReadCloser
return resp.Output, resp.Error
}
func (api *BlockAPI) Rm(ctx context.Context, p iface.Path, opts ...options.BlockRmOption) error {
return ErrNotImplemented
}
func (api *BlockAPI) Stat(ctx context.Context, p iface.Path) (iface.BlockStat, error) {
return nil, ErrNotImplemented
}
func (api *BlockAPI) core() *HttpApi {
return (*HttpApi)(api)
}