Socket
Socket
Sign inDemoInstall

github.com/RTradeLtd/swampi

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/RTradeLtd/swampi

Package swampi provides a golang client to interact with ethereum swarm http api's


Version published

Readme

Source

swampi

swampi is a golang client for the swarm http api, and enables programmatic access to the swarm API via your golang programs. It's primary purpose is for use with Temporal, but other users may find it useful.

format

Individual API calls are represented by a typed string call APICall. This allows reducing code surface for common task such as request handling, request formatting, etc..

The value of APICall instances is the actual HTTP path for the API call. For example single file upload is stored in code as APICall("/bzz:/"), so APICall::String will return the http path to be fed into http.NewRequest. Additionally methods like APICall::ContentType mean you don't have to deal with guessing the content type for requests as its done for you. Additionally certain API calls require url arguments, such as the single file download which takes the swarm hash. These are handled with APICall::ParseArgs.

usage

For more detailed usage instructions see the tests, but in essence it consists of:

// this creates our swampi client
swampi := New("http://localhost:8500")
fileBytes, err := ioutil.ReadFile(tt.args.filePath)
if err != nil {
	log.Fatal(err)
}
// handles parsing the api calls and sending it, returning the response
resp, err := swampi.Send(SingleFileUpload, bytes.NewReader(fileBytes), map[string][]string{
	"content-type": []string{SingleFileUpload.ContentType()},
})
if err != nil {
    log.Fatal(err)
}
// do stuff with response

FAQs

Last updated on 06 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc