Documentation
¶
Overview ¶
Package jsonstore is a client for the https://www.jsonstore.io API
Installation
go get -u github.com/peterhellberg/jsonstore
Usage
package main import ( "context" "fmt" "github.com/peterhellberg/jsonstore" ) const secret = "3ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf" type example struct { Number int Bool bool String string } func main() { ctx := context.Background() store := jsonstore.New(jsonstore.Secret(secret)) store.Post(ctx, "key", example{1234, true, "initial"}) store.Put(ctx, "key/String", "modified") store.Delete(ctx, "key/Bool") var e example store.Get(ctx, "key", &e) fmt.Printf("%s -> %+v\n", store.URL("key"), e) }
Index ¶
- Variables
- func NewSecret() (string, error)
- type Client
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) Get(ctx context.Context, path string, v interface{}) error
- func (c *Client) Post(ctx context.Context, path string, v interface{}) error
- func (c *Client) Put(ctx context.Context, path string, v interface{}) error
- func (c *Client) Secret() string
- func (c *Client) URL(segments ...string) *url.URL
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoSecret = fmt.Errorf("no secret") ErrNotFound = fmt.Errorf("not found") ErrInternalServerError = fmt.Errorf("internal server error") ErrUnexpectedStatus = fmt.Errorf("unexpected status") )
Errors
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the www.jsonstore.io API
Click to show internal directories.
Click to hide internal directories.